[spambayes-dev] Use of email factory function

Tony Meyer tameyer at ihug.co.nz
Tue Aug 3 02:11:56 CEST 2004


> I was wondering, instead of having the email parser create a new 
> instance and then copying over the internals, could we not 
> make use of the factory function argument?
> 
> We could call the parser like this:
> 
> new_msg = email.Parser.Parser(lambda x=self: 
> x).parsestr(data[self.rfc822_key])
> 
> The parser will call the factory function passed as its first 
> argument to get a new instance of a Message.  But we could also just
> use a factory function that returns the already existing instance (lambda 
> x=self: x) and then not copy over the internals.

I (think I) wrote that code, and I'm certainly hazy on many parts of the
email package and the parsers.  I didn't know that the above was possible (I
suspected something like it, but couldn't figure it out).

+1 to checking this in.

(I think that setPayload in spambayes.Message could then also do this, so
I'll look into that after this has been checked in a works :)

=Tony Meyer



More information about the spambayes-dev mailing list