diff options
Diffstat (limited to 'mailman/queue')
| -rw-r--r-- | mailman/queue/__init__.py | 9 | ||||
| -rw-r--r-- | mailman/queue/archive.py | 38 | ||||
| -rw-r--r-- | mailman/queue/outgoing.py | 9 | ||||
| -rw-r--r-- | mailman/queue/virgin.py | 20 |
4 files changed, 39 insertions, 37 deletions
diff --git a/mailman/queue/__init__.py b/mailman/queue/__init__.py index 4175babaa..17386cda6 100644 --- a/mailman/queue/__init__.py +++ b/mailman/queue/__init__.py @@ -38,6 +38,7 @@ import sha import time import email import errno +import pickle import cPickle import logging import marshal @@ -95,12 +96,12 @@ class Switchboard: listname = data.get('listname', '--nolist--') # Get some data for the input to the sha hash. now = time.time() - if not data.get('_plaintext'): - protocol = 1 - msgsave = cPickle.dumps(_msg, protocol) - else: + if data.get('_plaintext'): protocol = 0 msgsave = cPickle.dumps(str(_msg), protocol) + else: + protocol = pickle.HIGHEST_PROTOCOL + msgsave = cPickle.dumps(_msg, protocol) # listname is unicode but the input to the hash function must be an # 8-bit string (eventually, a bytes object). hashfood = msgsave + listname.encode('utf-8') + repr(now) diff --git a/mailman/queue/archive.py b/mailman/queue/archive.py index 854e4340f..013f8c949 100644 --- a/mailman/queue/archive.py +++ b/mailman/queue/archive.py @@ -28,6 +28,7 @@ __all__ = [ import os import time +from datetime import datetime from email.Utils import parsedate_tz, mktime_tz, formatdate from locknix.lockfile import Lock @@ -44,37 +45,38 @@ class ArchiveRunner(Runner): # Support clobber_date, i.e. setting the date in the archive to the # received date, not the (potentially bogus) Date: header of the # original message. - clobber = 0 - originaldate = msg.get('date') - receivedtime = formatdate(msgdata['received_time']) - if not originaldate: - clobber = 1 + clobber = False + original_date = msg.get('date') + received_time = formatdate(msgdata['received_time']) + if not original_date: + clobber = True elif config.ARCHIVER_CLOBBER_DATE_POLICY == 1: - clobber = 1 + clobber = True elif config.ARCHIVER_CLOBBER_DATE_POLICY == 2: - # what's the timestamp on the original message? - tup = parsedate_tz(originaldate) - now = time.time() + # What's the timestamp on the original message? + timetup = parsedate_tz(original_date) + now = datetime.now() try: - if not tup: - clobber = 1 - elif abs(now - mktime_tz(tup)) > \ - config.ARCHIVER_ALLOWABLE_SANE_DATE_SKEW: - clobber = 1 + if not timetup: + clobber = True + else: + utc_timestamp = datetime.fromtimestamp(mktime_tz(timetup)) + clobber = (abs(now - utc_timestamp) > + config.ARCHIVER_ALLOWABLE_SANE_DATE_SKEW) except (ValueError, OverflowError): # The likely cause of this is that the year in the Date: field # is horribly incorrect, e.g. (from SF bug # 571634): # Date: Tue, 18 Jun 0102 05:12:09 +0500 # Obviously clobber such dates. - clobber = 1 + clobber = True if clobber: del msg['date'] del msg['x-original-date'] - msg['Date'] = receivedtime + msg['Date'] = received_time if originaldate: - msg['X-Original-Date'] = originaldate + msg['X-Original-Date'] = original_date # Always put an indication of when we received the message. - msg['X-List-Received-Date'] = receivedtime + msg['X-List-Received-Date'] = received_time # While a list archiving lock is acquired, archive the message. with Lock(os.path.join(mlist.data_path, 'archive.lck')): for archive_factory in get_plugins('mailman.archiver'): diff --git a/mailman/queue/outgoing.py b/mailman/queue/outgoing.py index 4c067b8c0..399432e5d 100644 --- a/mailman/queue/outgoing.py +++ b/mailman/queue/outgoing.py @@ -23,7 +23,8 @@ import copy import email import socket import logging -import datetime + +from datetime import datetime from mailman import Errors from mailman import Message @@ -56,8 +57,8 @@ class OutgoingRunner(Runner, BounceMixin): def _dispose(self, mlist, msg, msgdata): # See if we should retry delivery of this message again. - deliver_after = msgdata.get('deliver_after', 0) - if datetime.datetime.now() < deliver_after: + deliver_after = msgdata.get('deliver_after', datetime.fromtimestamp(0)) + if datetime.now() < deliver_after: return True # Make sure we have the most up-to-date state try: @@ -102,7 +103,7 @@ class OutgoingRunner(Runner, BounceMixin): # occasionally move them back here for another shot at # delivery. if e.tempfailures: - now = datetime.datetime.now() + now = datetime.now() recips = e.tempfailures last_recip_count = msgdata.get('last_recip_count', 0) deliver_until = msgdata.get('deliver_until', now) diff --git a/mailman/queue/virgin.py b/mailman/queue/virgin.py index 5534c95f0..0494700ce 100644 --- a/mailman/queue/virgin.py +++ b/mailman/queue/virgin.py @@ -23,22 +23,20 @@ to go through some minimal processing before they can be sent out to the recipient. """ +from mailman.app.pipelines import process from mailman.configuration import config from mailman.queue import Runner -from mailman.queue.incoming import IncomingRunner -class VirginRunner(IncomingRunner): +class VirginRunner(Runner): QDIR = config.VIRGINQUEUE_DIR def _dispose(self, mlist, msg, msgdata): - # We need to fasttrack this message through any handlers that touch - # it. E.g. especially CookHeaders. - msgdata['_fasttrack'] = 1 - return IncomingRunner._dispose(self, mlist, msg, msgdata) - - def _get_pipeline(self, mlist, msg, msgdata): - # It's okay to hardcode this, since it'll be the same for all - # internally crafted messages. - return ['CookHeaders', 'ToOutgoing'] + # We need to fast track this message through any pipeline handlers + # that touch it, e.g. especially cook-headers. + msgdata['_fasttrack'] = True + # Use the 'virgin' pipeline. + process(mlist, msg, msgdata, 'virgin') + # Do not keep this message queued. + return False |
