[Fwd: [Email-SIG] persisting email.Message.Message instances]

Tim Hicks tim at sitefusion.co.uk
Sat Jan 15 20:59:42 CET 2005


Hello all,

I'm just re-sending this message.  I guess it got lost in the holiday
season...

tim

---------------------------- Original Message ----------------------------
Subject: [Email-SIG] persisting email.Message.Message instances
From:    "Tim Hicks" <tim at sitefusion.co.uk>
Date:    Sun, December 26, 2004 5:17 pm
To:      email-sig at python.org
--------------------------------------------------------------------------

Hi all,

I'm trying to come up with the best way to persist Message instances
(using ZODB).  After playing around for a bit, I came up with some code
that works (I think).  If you look at
<http://cvs.sourceforge.net/viewcvs.py/collective/atemail/persistentmessage.py?rev=1.2&view=auto>,
you can see what I've done.  The PersistentMessage class is my second
attempt, while the DeeplyPersistentMessage class was my first (rather
flawed) attempt.

The reason I'm writing to the list is that I've realised a couple of
things that I'd quite like the email package to offer, so I thought I'd
ask.

My PersistentMessage class seems like a fair few too many LOC for what it
really does.  If email.Message.Message automatically called a specific
method, say '_ob_changed' whenever the instance was changed, with a
default implementation looking like::

  def _ob_changed(self):
    pass

then my PersistentMessage implementation could simply look like::

  class PersistentMessage(Message, Persistent):

    def _ob_changed(self):
      self._p_changed = True

Does this sound like a good idea?


The second thing is that I think I want to be able to specify the
class/factory that is used when Message sub-parts are constructed.  That
is, I want each message-part of my PersistentMessage instances to also be
PersistentMessage instances.  This is because I want to (a) stop ZODB
bloat when I make changes to message attachments where other (potentially
large) attachments are also present; (b) have the benefits of the solution
to the _ob_changed method outlined above; (c) have security declarations
from Zope3 ZCML in effect; (d) related to b and c, not have to worry about
protecting PersistentMessage methods that return objects (i.e.
message-parts) that can then be mutated in place.

I hope that all makes sense.  Comments and guidance very much appreciated.


cheers,


Tim
_______________________________________________
Email-SIG mailing list
Email-SIG at python.org
Your options:
http://mail.python.org/mailman/options/email-sig/tim%40sitefusion.co.uk




More information about the Email-SIG mailing list