diff options
| author | Barry Warsaw | 2008-12-26 09:04:33 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-12-26 09:04:33 -0500 |
| commit | 1ffa4c74935a56a3c5de736fab052e33e4ab3d38 (patch) | |
| tree | e44781f9de6e2ab284990000c08772664e999a5f /mailman/queue | |
| parent | b8e68e7577aa12e0e355aabe2845981f0d73e3b5 (diff) | |
| download | mailman-1ffa4c74935a56a3c5de736fab052e33e4ab3d38.tar.gz mailman-1ffa4c74935a56a3c5de736fab052e33e4ab3d38.tar.zst mailman-1ffa4c74935a56a3c5de736fab052e33e4ab3d38.zip | |
Diffstat (limited to 'mailman/queue')
| -rw-r--r-- | mailman/queue/bounce.py | 27 | ||||
| -rw-r--r-- | mailman/queue/docs/outgoing.txt | 5 | ||||
| -rw-r--r-- | mailman/queue/outgoing.py | 13 |
3 files changed, 23 insertions, 22 deletions
diff --git a/mailman/queue/bounce.py b/mailman/queue/bounce.py index 18fa08437..9f390130d 100644 --- a/mailman/queue/bounce.py +++ b/mailman/queue/bounce.py @@ -27,6 +27,7 @@ from email.MIMEMessage import MIMEMessage from email.MIMEText import MIMEText from email.Utils import parseaddr +from mailman import Defaults from mailman import Utils from mailman.Bouncers import BouncerAPI from mailman.Message import UserNotification @@ -80,7 +81,7 @@ class BounceMixin: self._bounce_events_fp = None self._bouncecnt = 0 self._nextaction = (datetime.datetime.now() + - config.REGISTER_BOUNCES_EVERY) + Defaults.REGISTER_BOUNCES_EVERY) def _queue_bounces(self, listname, addrs, msg): today = datetime.date.today() @@ -132,7 +133,7 @@ class BounceMixin: if self._nextaction > now or self._bouncecnt == 0: return # Let's go ahead and register the bounces we've got stored up - self._nextaction = now + config.REGISTER_BOUNCES_EVERY + self._nextaction = now + Defaults.REGISTER_BOUNCES_EVERY self._register_bounces() def _probe_bounce(self, mlist, token): @@ -153,7 +154,7 @@ class BounceMixin: class BounceRunner(Runner, BounceMixin): - QDIR = config.BOUNCEQUEUE_DIR + """The bounce runner.""" def __init__(self, slice=None, numslices=1): Runner.__init__(self, slice, numslices) @@ -162,7 +163,6 @@ class BounceRunner(Runner, BounceMixin): def _dispose(self, mlist, msg, msgdata): # Make sure we have the most up-to-date state mlist.Load() - outq = Switchboard(config.OUTQUEUE_DIR) # There are a few possibilities here: # # - the message could have been VERP'd in which case, we know exactly @@ -176,14 +176,15 @@ class BounceRunner(Runner, BounceMixin): # owner address. That way, if a list owner address bounces, at least # some human has a chance to deal with it. Is this a bounce for a # message to a list owner, coming to the site owner? - if msg.get('to', '') == config.SITE_OWNER_ADDRESS: + if msg.get('to', '') == config.mailman.site_owner: # Send it on to the site owners, but craft the envelope sender to # be the noreply address, so if the site owner bounce, we won't # get stuck in a bounce loop. - outq.enqueue(msg, msgdata, - recips=[config.SITE_OWNER_ADDRESS], - envsender=config.NO_REPLY_ADDRESS, - ) + config.switchboards['out'].enqueue( + msg, msgdata, + recips=[config.mailman.site_owner], + envsender=config.mailman.noreply_address, + ) # List isn't doing bounce processing? if not mlist.bounce_processing: return @@ -241,7 +242,7 @@ def verp_bounce(mlist, msg): to = parseaddr(field)[1] if not to: continue # empty header - mo = re.search(config.VERP_REGEXP, to) + mo = re.search(Defaults.VERP_REGEXP, to) if not mo: continue # no match of regexp try: @@ -251,7 +252,7 @@ def verp_bounce(mlist, msg): addr = '%s@%s' % mo.group('mailbox', 'host') except IndexError: elog.error("VERP_REGEXP doesn't yield the right match groups: %s", - config.VERP_REGEXP) + Defaults.VERP_REGEXP) return [] return [addr] @@ -272,7 +273,7 @@ def verp_probe(mlist, msg): to = parseaddr(field)[1] if not to: continue # empty header - mo = re.search(config.VERP_PROBE_REGEXP, to) + mo = re.search(Defaults.VERP_PROBE_REGEXP, to) if not mo: continue # no match of regexp try: @@ -286,7 +287,7 @@ def verp_probe(mlist, msg): except IndexError: elog.error( "VERP_PROBE_REGEXP doesn't yield the right match groups: %s", - config.VERP_PROBE_REGEXP) + Defaults.VERP_PROBE_REGEXP) return None diff --git a/mailman/queue/docs/outgoing.txt b/mailman/queue/docs/outgoing.txt index 9af554af7..851bdf474 100644 --- a/mailman/queue/docs/outgoing.txt +++ b/mailman/queue/docs/outgoing.txt @@ -47,8 +47,7 @@ injecting a message directly into the outgoing queue. >>> handler = config.handlers['calculate-recipients'] >>> handler.process(mlist, msg, msgdata) - >>> from mailman.queue import Switchboard - >>> outgoing_queue = Switchboard(config.OUTQUEUE_DIR) + >>> outgoing_queue = config.switchboards['out'] >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, ... verp=True, listname=mlist.fqdn_listname, tolist=True, @@ -59,7 +58,7 @@ upstream SMTP, which happens to be our test server. >>> from mailman.queue.outgoing import OutgoingRunner >>> from mailman.testing.helpers import make_testable_runner - >>> outgoing = make_testable_runner(OutgoingRunner) + >>> outgoing = make_testable_runner(OutgoingRunner, 'out') >>> outgoing.run() Three messages have been delivered to our SMTP server, one for each recipient. diff --git a/mailman/queue/outgoing.py b/mailman/queue/outgoing.py index 9eb287e6b..2043d8bc8 100644 --- a/mailman/queue/outgoing.py +++ b/mailman/queue/outgoing.py @@ -26,6 +26,7 @@ import logging from datetime import datetime +from mailman import Defaults from mailman import Message from mailman.config import config from mailman.core import errors @@ -41,19 +42,19 @@ log = logging.getLogger('mailman.error') class OutgoingRunner(Runner, BounceMixin): - QDIR = config.OUTQUEUE_DIR + """The outgoing queue runner.""" def __init__(self, slice=None, numslices=1): Runner.__init__(self, slice, numslices) BounceMixin.__init__(self) # We look this function up only at startup time - handler = config.handlers[config.DELIVERY_MODULE] + handler = config.handlers[Defaults.DELIVERY_MODULE] self._func = handler.process # This prevents smtp server connection problems from filling up the # error log. It gets reset if the message was successfully sent, and # set if there was a socket.error. self._logged = False - self._retryq = Switchboard(config.RETRYQUEUE_DIR) + self._retryq = config.switchboards['retry'] def _dispose(self, mlist, msg, msgdata): # See if we should retry delivery of this message again. @@ -73,13 +74,13 @@ class OutgoingRunner(Runner, BounceMixin): # There was a problem connecting to the SMTP server. Log this # once, but crank up our sleep time so we don't fill the error # log. - port = config.SMTPPORT + port = int(config.mta.port) if port == 0: port = 'smtp' # Log this just once. if not self._logged: log.error('Cannot connect to SMTP server %s on port %s', - config.SMTPHOST, port) + config.mta.host, port) self._logged = True return True except errors.SomeRecipientsFailed, e: @@ -115,7 +116,7 @@ class OutgoingRunner(Runner, BounceMixin): return False else: # Keep trying to delivery this message for a while - deliver_until = now + config.DELIVERY_RETRY_PERIOD + deliver_until = now + Defaults.DELIVERY_RETRY_PERIOD msgdata['last_recip_count'] = len(recips) msgdata['deliver_until'] = deliver_until msgdata['recips'] = recips |
