Bug in rfc822

Barry A. Warsaw barry at digicool.com
Wed Jul 11 17:58:07 CEST 2001


>>>>> "EJ" == Emmanuel Jeandel <ejeandel at ens-lyon.fr> writes:

    EJ> Playing with rfc822 is good, but i think mailbox.py has also
    EJ> several problems. When you do mailbox.next(), the function
    EJ> return a rfc822.Message but i wanted to use my class
    EJ> MyMessage, so i have to rewrite :

I added a default argument to the _Mailbox class in Python 2.2's
mailbox.py module:

    class _Mailbox:
	def __init__(self, fp, factory=rfc822.Message):
	    self.fp = fp
	    self.seekp = 0
	    self.factory = factory

so when a new mail message object needs to be created, it'll call
self.factory (i.e. factory must be a callable).  I use this in Mailman
to create instances of my own Message class (subclassed from
mimelib.Message.Message).

Python 2.2's mailbox.py should be compatible with earlier versions of
Python, and if you don't have cvs access, you can grab it from

    http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Lib/mailbox.py?rev=1.31&content-type=text/vnd.viewcvs-markup

Hope that helps,
-Barry




More information about the Python-list mailing list