diff options
| author | Barry Warsaw | 2009-01-06 19:55:59 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-01-06 19:55:59 -0500 |
| commit | 89f5f76ed31d6ca2faf8e2a783a37e9009b03413 (patch) | |
| tree | f1023f64501a49917674f5bcd78927aa5cee08ef /mailman/queue | |
| parent | 37c255b7b0c1b8ea10c8d24a44c8586de86ffcc6 (diff) | |
| download | mailman-89f5f76ed31d6ca2faf8e2a783a37e9009b03413.tar.gz mailman-89f5f76ed31d6ca2faf8e2a783a37e9009b03413.tar.zst mailman-89f5f76ed31d6ca2faf8e2a783a37e9009b03413.zip | |
The conversion from Defaults.py to lazr.config is complete.
lazr.config 1.1 now has everything we need, so we don't need the special
develop hack.
make_instance is no longer necessary.
Refactor the style stuff into their own directory.
Finally! Move the delivery module into the mailman.mta package.
Diffstat (limited to 'mailman/queue')
| -rw-r--r-- | mailman/queue/archive.py | 12 | ||||
| -rw-r--r-- | mailman/queue/bounce.py | 22 | ||||
| -rw-r--r-- | mailman/queue/command.py | 8 | ||||
| -rw-r--r-- | mailman/queue/lmtp.py | 9 | ||||
| -rw-r--r-- | mailman/queue/news.py | 17 | ||||
| -rw-r--r-- | mailman/queue/outgoing.py | 13 |
6 files changed, 42 insertions, 39 deletions
diff --git a/mailman/queue/archive.py b/mailman/queue/archive.py index c97bd86fb..75e8569e0 100644 --- a/mailman/queue/archive.py +++ b/mailman/queue/archive.py @@ -30,10 +30,9 @@ import logging from datetime import datetime from email.Utils import parsedate_tz, mktime_tz, formatdate -from lazr.config import as_boolean +from lazr.config import as_boolean, as_timedelta from locknix.lockfile import Lock -from mailman import Defaults from mailman.config import config from mailman.queue import Runner @@ -53,9 +52,9 @@ class ArchiveRunner(Runner): received_time = formatdate(msgdata['received_time']) if not original_date: clobber = True - elif Defaults.ARCHIVER_CLOBBER_DATE_POLICY == 1: + elif int(config.archiver.pipermail.clobber_date_policy) == 1: clobber = True - elif Defaults.ARCHIVER_CLOBBER_DATE_POLICY == 2: + elif int(config.archiver.pipermail.clobber_date_policy) == 2: # What's the timestamp on the original message? timetup = parsedate_tz(original_date) now = datetime.now() @@ -64,8 +63,9 @@ class ArchiveRunner(Runner): clobber = True else: utc_timestamp = datetime.fromtimestamp(mktime_tz(timetup)) - clobber = (abs(now - utc_timestamp) > - Defaults.ARCHIVER_ALLOWABLE_SANE_DATE_SKEW) + date_skew = as_timedelta( + config.archiver.pipermail.allowable_sane_date_skew) + clobber = (abs(now - utc_timestamp) > 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): diff --git a/mailman/queue/bounce.py b/mailman/queue/bounce.py index ce5040982..ced731d6d 100644 --- a/mailman/queue/bounce.py +++ b/mailman/queue/bounce.py @@ -24,8 +24,8 @@ import logging import datetime from email.Utils import parseaddr +from lazr.config import as_timedelta -from mailman import Defaults from mailman import Utils from mailman.Bouncers import BouncerAPI from mailman.config import config @@ -77,8 +77,9 @@ class BounceMixin: config.DATA_DIR, 'bounce-events-%05d.pck' % os.getpid()) self._bounce_events_fp = None self._bouncecnt = 0 - self._nextaction = (datetime.datetime.now() + - Defaults.REGISTER_BOUNCES_EVERY) + self._nextaction = ( + datetime.datetime.now() + + as_timedelta(config.bounces.register_bounces_every)) def _queue_bounces(self, listname, addrs, msg): today = datetime.date.today() @@ -130,7 +131,8 @@ 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 + Defaults.REGISTER_BOUNCES_EVERY + self._nextaction = now + as_timedelta( + config.bounces.register_bounces_every) self._register_bounces() def _probe_bounce(self, mlist, token): @@ -239,7 +241,7 @@ def verp_bounce(mlist, msg): to = parseaddr(field)[1] if not to: continue # empty header - mo = re.search(Defaults.VERP_REGEXP, to) + mo = re.search(config.mta.verp_regexp, to) if not mo: continue # no match of regexp try: @@ -248,8 +250,8 @@ def verp_bounce(mlist, msg): # All is good addr = '%s@%s' % mo.group('mailbox', 'host') except IndexError: - elog.error("VERP_REGEXP doesn't yield the right match groups: %s", - Defaults.VERP_REGEXP) + elog.error("verp_regexp doesn't yield the right match groups: %s", + config.mta.verp_regexp) return [] return [addr] @@ -270,7 +272,7 @@ def verp_probe(mlist, msg): to = parseaddr(field)[1] if not to: continue # empty header - mo = re.search(Defaults.VERP_PROBE_REGEXP, to) + mo = re.search(config.mta.verp_probe_regexp, to) if not mo: continue # no match of regexp try: @@ -283,8 +285,8 @@ def verp_probe(mlist, msg): return token except IndexError: elog.error( - "VERP_PROBE_REGEXP doesn't yield the right match groups: %s", - Defaults.VERP_PROBE_REGEXP) + "verp_probe_regexp doesn't yield the right match groups: %s", + config.mta.verp_probe_regexp) return None diff --git a/mailman/queue/command.py b/mailman/queue/command.py index 45c9693b5..d2be7c9fd 100644 --- a/mailman/queue/command.py +++ b/mailman/queue/command.py @@ -37,7 +37,6 @@ from email.Header import decode_header, make_header from email.Iterators import typed_subpart_iterator from zope.interface import implements -from mailman import Defaults from mailman import Message from mailman.config import config from mailman.i18n import _ @@ -66,7 +65,7 @@ class CommandFinder: elif msgdata.get('toleave'): self.command_lines.append('leave') elif msgdata.get('toconfirm'): - mo = re.match(Defaults.VERP_CONFIRM_REGEXP, msg.get('to', '')) + mo = re.match(config.mta.verp_confirm_regexp, msg.get('to', '')) if mo: self.command_lines.append('confirm ' + mo.group('cookie')) # Extract the subject header and do RFC 2047 decoding. @@ -95,8 +94,9 @@ class CommandFinder: assert isinstance(body, basestring), 'Non-string decoded payload' lines = body.splitlines() # Use no more lines than specified - self.command_lines.extend(lines[:Defaults.EMAIL_COMMANDS_MAX_LINES]) - self.ignored_lines.extend(lines[Defaults.EMAIL_COMMANDS_MAX_LINES:]) + max_lines = int(config.mailman.email_commands_max_lines) + self.command_lines.extend(lines[:max_lines]) + self.ignored_lines.extend(lines[max_lines:]) def __iter__(self): """Return each command line, split into commands and arguments. diff --git a/mailman/queue/lmtp.py b/mailman/queue/lmtp.py index f52c99fae..3ac8796ca 100644 --- a/mailman/queue/lmtp.py +++ b/mailman/queue/lmtp.py @@ -29,9 +29,6 @@ so that the peer mail server can provide better diagnostics. [1] RFC 2033 Local Mail Transport Protocol http://www.faqs.org/rfcs/rfc2033.html - -See the variable USE_LMTP in Defaults.py.in for enabling this delivery -mechanism. """ import email @@ -41,7 +38,6 @@ import asyncore from email.utils import parseaddr -from mailman import Defaults from mailman.Message import Message from mailman.config import config from mailman.database.transaction import txn @@ -63,7 +59,7 @@ CRLF = '\r\n' ERR_451 = '451 Requested action aborted: error in processing' ERR_501 = '501 Message has defects' ERR_502 = '502 Error: command HELO not implemented' -ERR_550 = Defaults.LMTP_ERR_550 +ERR_550 = '550 Requested action not taken: mailbox unavailable' # XXX Blech smtpd.__version__ = 'Python LMTP queue runner 1.0' @@ -86,7 +82,7 @@ def split_recipient(address): subaddress may be None if this is the list's posting address. """ localpart, domain = address.split('@', 1) - localpart = localpart.split(Defaults.VERP_DELIMITER, 1)[0] + localpart = localpart.split(config.mta.verp_delimiter, 1)[0] parts = localpart.split(DASH) if parts[-1] in SUBADDRESS_NAMES: listname = DASH.join(parts[:-1]) @@ -186,7 +182,6 @@ class LMTPRunner(Runner, smtpd.SMTPServer): msgdata.update(dict( toowner=True, envsender=config.mailman.site_owner, - pipeline=Defaults.OWNER_PIPELINE, )) queue = 'in' elif subaddress is None: diff --git a/mailman/queue/news.py b/mailman/queue/news.py index ec744208d..ed408c72e 100644 --- a/mailman/queue/news.py +++ b/mailman/queue/news.py @@ -25,15 +25,15 @@ import nntplib from cStringIO import StringIO -COMMASPACE = ', ' - -from mailman import Defaults from mailman import Utils +from mailman.config import config from mailman.interfaces import NewsModeration from mailman.queue import Runner +COMMASPACE = ', ' log = logging.getLogger('mailman.error') + # Matches our Mailman crafted Message-IDs. See Utils.unique_message_id() # XXX The move to email.utils.make_msgid() breaks this. mcre = re.compile(r""" @@ -64,8 +64,8 @@ class NewsRunner(Runner): nntp_host, nntp_port = Utils.nntpsplit(mlist.nntp_host) conn = nntplib.NNTP(nntp_host, nntp_port, readermode=True, - user=Defaults.NNTP_USERNAME, - password=Defaults.NNTP_PASSWORD) + user=config.nntp.username, + password=config.nntp.password) conn.post(fp) except nntplib.error_temp, e: log.error('(NNTPDirect) NNTP error for list "%s": %s', @@ -147,9 +147,12 @@ def prepare_message(mlist, msg, msgdata): # woon't completely sanitize the message, but it will eliminate the bulk # of the rejections based on message headers. The NNTP server may still # reject the message because of other problems. - for header in Defaults.NNTP_REMOVE_HEADERS: + for header in config.nntp.remove_headers.split(): del msg[header] - for header, rewrite in Defaults.NNTP_REWRITE_DUPLICATE_HEADERS: + for rewrite_pairs in config.nntp.rewrite_duplicate_headers.splitlines(): + if len(rewrite_pairs.strip()) == 0: + continue + header, rewrite = rewrite_pairs.split() values = msg.get_all(header, []) if len(values) < 2: # We only care about duplicates diff --git a/mailman/queue/outgoing.py b/mailman/queue/outgoing.py index ed648cca0..fdb1289fd 100644 --- a/mailman/queue/outgoing.py +++ b/mailman/queue/outgoing.py @@ -18,12 +18,13 @@ """Outgoing queue runner.""" import os +import sys import socket import logging from datetime import datetime +from lazr.config import as_timedelta -from mailman import Defaults from mailman.config import config from mailman.core import errors from mailman.queue import Runner @@ -43,9 +44,10 @@ class OutgoingRunner(Runner, BounceMixin): 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[Defaults.DELIVERY_MODULE] - self._func = handler.process + # We look this function up only at startup time. + module_name, callable_name = config.mta.outgoing.rsplit('.', 1) + __import__(module_name) + self._func = getattr(sys.modules[module_name], callable_name) # 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. @@ -112,7 +114,8 @@ class OutgoingRunner(Runner, BounceMixin): return False else: # Keep trying to delivery this message for a while - deliver_until = now + Defaults.DELIVERY_RETRY_PERIOD + deliver_until = now + as_timedelta( + config.mta.delivery_retry_period) msgdata['last_recip_count'] = len(recips) msgdata['deliver_until'] = deliver_until msgdata['recips'] = recips |
