[Email-SIG] API thoughts
R. David Murray
rdmurray at bitdance.com
Thu Mar 3 01:50:20 CET 2011
On Wed, 02 Mar 2011 21:40:39 +0100, Steffen Daode Nurpmeso <sdaoden at googlemail.com> wrote:
> But if "what goes in .defects[]" will be configurable i would hope
> for a generic is_malformed() and maybe is_processable() or the
> like, i.e. state versus (translatable?) user-info.
I'm not sure what you are asking for here. I think "if msg.is_malformed()"
is spelled "if msg.defects". That is, if the defects list is non-empty,
the message is technically malformed. Of course, that information by
itself isn't necessarily useful, which is why defects is a list
of defects. "is_processable" lies in the eyes of the application.
What defects is it capable of dealing with? The email package
can't know that. So, again, that's why defects is a list.
Let me clarify what I mean by the policy controlling "what, exactly, is
a defect". The idea here is that when parsing an email, each deviance
from the RFCs counts as a defect (the current email package, by the way,
only detects a small number of such defects!). But when parsing, say,
an http stream, non-ascii characters in headers are perfectly legal.
So it seems to make sense that the HTTP policy would change what counts
as a defect during the operation of the parser.
> (The more i think about it the more i agree with David (i hope
> i don't lie about that) that it's a waste of time to try to
> convert malformed data to a compliant state, especially if the
> package is - by design - capable to spit out the data the very
> same way it came in. Someone will take care - and throw it away.)
Well, I think we may provide some tools to do such "fixups" when it is
possible and the application wants it. But they should be app-requested
transformations, not automatic ones.
> Unfortunately my non-hate mail seems to have been mistreated as
> spam 8-}, therefore i wrote all of the above just to thank David
> once again for making the email and mailbox packages usable
> already in Python 3.2. Thanks.
You are welcome :)
--David
More information about the Email-SIG
mailing list