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

R. David Murray rdmurray at bitdance.com
Thu Apr 16 03:19:44 CEST 2009


On Wed, 15 Apr 2009 at 20:39, Tony Nelson wrote:
> 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.

The first part of that is too magical and inconsistent for my tastes.
I want message['fooheader'] to return a Header object.  Which yes,
should contain the parsed token structure and be able to regenerate the
original bytes on demand (or vice versa, or keeping both the original
bytes and the parse tree if the parse tree is lossy).

For a header involving a list of addresses, I'd expect to get back a
Header subclass that I could iterate over to get individual Address
objects.  For other structured headers, I'd expect to get a subclass
with useful methods and attributes for accessing the structure.

And when I str the Header (for example, when presenting one or more
selected headers to a user), I would expect to get a string that a
user would expect to read, which is to say a fully-decoded-to-unicode
user-oriented representation of the structured data as one long string
(I'll do any folding formatting for presentation as needed).

Going the other way I have fewer opinions about, as I haven't written
any code to do that yet :)

--David


More information about the Email-SIG mailing list