Update of /cvsroot/mailman/mailman/Mailman
In directory usw-pr-cvs1:/tmp/cvs-serv17901

Modified Files:
        ListAdmin.py 
Log Message:
HOLD_MESSAGES_AS_PICKLES: Flag to choose whether the held messages are
saved on disk as pickles or plaintext.  I don't want to promote this
to a mm_cfg.py variable.

HoldMessage(): Optionally store the message in plain text.


Index: ListAdmin.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/ListAdmin.py,v
retrieving revision 2.33
retrieving revision 2.34
diff -C2 -d -r2.33 -r2.34
*** ListAdmin.py        26 Mar 2002 20:44:05 -0000      2.33
--- ListAdmin.py        1 Apr 2002 17:49:59 -0000       2.34
***************
*** 29,35 ****
  import errno
  import cPickle
  import email
  from email.MIMEMessage import MIMEMessage
! from cStringIO import StringIO
  
  from Mailman import mm_cfg
--- 29,37 ----
  import errno
  import cPickle
+ from cStringIO import StringIO
+ 
  import email
  from email.MIMEMessage import MIMEMessage
! from email.Generator import Generator
  
  from Mailman import mm_cfg
***************
*** 58,61 ****
--- 60,69 ----
  NL = '\n'
  
+ # Should held messages be saved on disk as Python pickles or as plain text?
+ # The former is more efficient since we don't need to go through the
+ # parse/generate roundtrip each time, but the latter might be preferred if you
+ # want to edit the held message on disk.
+ HOLD_MESSAGES_AS_PICKLES = 1
+ 
  
  
***************
*** 201,210 ****
          sender = msg.get_sender()
          # calculate the file name for the message text and write it to disk
!         filename = 'heldmsg-%s-%d.pck' % (self.internal_name(), id)
          omask = os.umask(002)
          fp = None
          try:
              fp = open(os.path.join(mm_cfg.DATA_DIR, filename), 'w')
!             cPickle.dump(msg, fp, 1)
          finally:
              if fp:
--- 209,226 ----
          sender = msg.get_sender()
          # calculate the file name for the message text and write it to disk
!         if HOLD_MESSAGES_AS_PICKLES:
!             ext = 'pck'
!         else:
!             ext = 'txt'
!         filename = 'heldmsg-%s-%d.%s' % (self.internal_name(), id, ext)
          omask = os.umask(002)
          fp = None
          try:
              fp = open(os.path.join(mm_cfg.DATA_DIR, filename), 'w')
!             if HOLD_MESSAGES_AS_PICKLES:
!                 cPickle.dump(msg, fp, 1)
!             else:
!                 g = Generator(fp)
!                 g(msg, 1)
          finally:
              if fp:


_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins

Reply via email to