summaryrefslogtreecommitdiff
path: root/Mailman/ListAdmin.py
diff options
context:
space:
mode:
Diffstat (limited to 'Mailman/ListAdmin.py')
-rw-r--r--Mailman/ListAdmin.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/Mailman/ListAdmin.py b/Mailman/ListAdmin.py
index 98252a365..e1eb89425 100644
--- a/Mailman/ListAdmin.py
+++ b/Mailman/ListAdmin.py
@@ -28,9 +28,11 @@ import time
import marshal
import errno
import cPickle
+from cStringIO import StringIO
+
import email
from email.MIMEMessage import MIMEMessage
-from cStringIO import StringIO
+from email.Generator import Generator
from Mailman import mm_cfg
from Mailman import Utils
@@ -57,6 +59,12 @@ LOST = 2
DASH = '-'
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
+
class ListAdmin:
@@ -200,12 +208,20 @@ class ListAdmin:
# get the message sender
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)
+ 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')
- cPickle.dump(msg, fp, 1)
+ if HOLD_MESSAGES_AS_PICKLES:
+ cPickle.dump(msg, fp, 1)
+ else:
+ g = Generator(fp)
+ g(msg, 1)
finally:
if fp:
fp.close()