[Email-SIG] API for Header objects [was: Dropping bytes "support" in json]

Stephen J. Turnbull stephen at xemacs.org
Thu Apr 16 08:24:47 CEST 2009


Tony Nelson writes:

 > strings, some is lists of address pairs, and so on.  If the data
 > for a header field is not properly a string, a means to get it as
 > one is wrong.

Er, but the data for an address field is not "properly" a list of
pairs, either.  So I guess you would agree that a means to get it as
one is wrong, then?

 > All the grotty internals of Heaer objects would be accessible by
 > fetching the Header object with "msg.get_header('name')".
 > "msg[...]" is an abbreviation for convenience which should not
 > mislead users or be complex or magical in action.

A message or so back you made the point that an address header is a
rather complex object that is *not* easy to parse.  For example (this
is a trick question), in your opinion, what should

    msg['To'][0]

return if the original header was

To: Stephen J. Turnbull <stephen at xemacs.org>

?

 > Internally, the Header whose .useful attribute is returned by
 > "msg['foo']" will contain parsed data, referring to parsed tokens.
 > Flattening those parsed tokens will produce the original data.  Not
 > a problem at all, simple to implement, in the most direct way.

And horrid to use, if you mean that the internal representation will
be a full parse tree according to the augmented BNF in RFCs 822, 2822,
5322, 2045-2049, etc etc., and that the only other way to access that
data is via an arbitrarily defined .useful attribute (which, BTW, is
quite unpythonic if you intend for it to be available as msg['foo'] as
well: TOOWTDI).


More information about the Email-SIG mailing list