From ccb90b99cbe5168bcd3b72e3277ab5ec02e8156a Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Mon, 15 Oct 2001 21:37:00 +0000 Subject: _factory(): A factory function for PortableUnixMailbox.__init__() so that any new message objects it creates will be instances of our Message class instead of rfc822's. Mailbox.__init__(): Pass our _factory to base class constructor. --- Mailman/Mailbox.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Mailman/Mailbox.py b/Mailman/Mailbox.py index df8670fb9..2d61427af 100644 --- a/Mailman/Mailbox.py +++ b/Mailman/Mailbox.py @@ -18,11 +18,27 @@ "Extend mailbox.UnixMailbox." from email.Generator import Generator +from email.Parser import Parser + +from Mailman.Message import Message from Mailman.pythonlib import mailbox + + +# Factory callable for UnixMailboxes. This ensures that any object we get out +# of the mailbox is an instance of our subclass. (requires Python 2.1's +# mailbox module) +def _factory(fp): + p = Parser(Message) + return p.parse(fp) + + class Mailbox(mailbox.PortableUnixMailbox): + def __init__(self, fp): + mailbox.PortableUnixMailbox.__init__(self, fp, _factory) + # msg should be an rfc822 message or a subclass. def AppendMessage(self, msg): # Check the last character of the file and write a newline if it isn't -- cgit v1.3.1