diff options
Diffstat (limited to 'mailman/pipeline')
40 files changed, 145 insertions, 176 deletions
diff --git a/mailman/pipeline/__init__.py b/mailman/pipeline/__init__.py index b59953f47..a77e00915 100644 --- a/mailman/pipeline/__init__.py +++ b/mailman/pipeline/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2008 by the Free Software Foundation, Inc. +# Copyright (C) 2008-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # diff --git a/mailman/pipeline/acknowledge.py b/mailman/pipeline/acknowledge.py index 41fc931ae..57817b6b0 100644 --- a/mailman/pipeline/acknowledge.py +++ b/mailman/pipeline/acknowledge.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -28,7 +28,7 @@ from zope.interface import implements from mailman import Message from mailman import Utils -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.interfaces import IHandler diff --git a/mailman/pipeline/after_delivery.py b/mailman/pipeline/after_delivery.py index 5d062462a..e5bc98fcd 100644 --- a/mailman/pipeline/after_delivery.py +++ b/mailman/pipeline/after_delivery.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # diff --git a/mailman/pipeline/avoid_duplicates.py b/mailman/pipeline/avoid_duplicates.py index d228c6ad9..ddfbc4578 100644 --- a/mailman/pipeline/avoid_duplicates.py +++ b/mailman/pipeline/avoid_duplicates.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2002-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -30,7 +30,7 @@ __all__ = ['AvoidDuplicates'] from email.Utils import getaddresses, formataddr from zope.interface import implements -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.interfaces import IHandler diff --git a/mailman/pipeline/calculate_recipients.py b/mailman/pipeline/calculate_recipients.py index f892435cd..18d237ec0 100644 --- a/mailman/pipeline/calculate_recipients.py +++ b/mailman/pipeline/calculate_recipients.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -30,7 +30,7 @@ from zope.interface import implements from mailman import Message from mailman import Utils -from mailman.configuration import config +from mailman.config import config from mailman.core import errors from mailman.i18n import _ from mailman.interfaces import DeliveryStatus, IHandler diff --git a/mailman/pipeline/cleanse.py b/mailman/pipeline/cleanse.py index f381d78e1..a2b19545e 100644 --- a/mailman/pipeline/cleanse.py +++ b/mailman/pipeline/cleanse.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # diff --git a/mailman/pipeline/cleanse_dkim.py b/mailman/pipeline/cleanse_dkim.py index ae51fc27c..4edd8193d 100644 --- a/mailman/pipeline/cleanse_dkim.py +++ b/mailman/pipeline/cleanse_dkim.py @@ -1,4 +1,4 @@ -# Copyright (C) 2006-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2006-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -31,7 +31,7 @@ __all__ = ['CleanseDKIM'] from zope.interface import implements -from mailman.configuration import config +from mailman import Defaults from mailman.i18n import _ from mailman.interfaces import IHandler @@ -47,7 +47,7 @@ class CleanseDKIM: def process(self, mlist, msg, msgdata): """See `IHandler`.""" - if config.REMOVE_DKIM_HEADERS: + if Defaults.REMOVE_DKIM_HEADERS: del msg['domainkey-signature'] del msg['dkim-signature'] del msg['authentication-results'] diff --git a/mailman/pipeline/cook_headers.py b/mailman/pipeline/cook_headers.py index 362c8ecf7..a37a92a69 100644 --- a/mailman/pipeline/cook_headers.py +++ b/mailman/pipeline/cook_headers.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -32,7 +32,7 @@ from email.utils import parseaddr, formataddr, getaddresses from zope.interface import implements from mailman import Utils -from mailman.configuration import config +from mailman.config import config from mailman.core.plugins import get_plugins from mailman.i18n import _ from mailman.interfaces import IHandler, Personalization, ReplyToMunging diff --git a/mailman/pipeline/decorate.py b/mailman/pipeline/decorate.py index 3e9c6360b..3059bde38 100644 --- a/mailman/pipeline/decorate.py +++ b/mailman/pipeline/decorate.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -28,9 +28,10 @@ from email.MIMEText import MIMEText from string import Template from zope.interface import implements +from mailman import Defaults from mailman import Utils from mailman.Message import Message -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.interfaces import IHandler @@ -204,7 +205,7 @@ def decorate(mlist, template, extradict=None): web_page_url = mlist.web_page_url, description = mlist.description, info = mlist.info, - cgiext = config.CGIEXT, + cgiext = Defaults.CGIEXT, ) if extradict is not None: d.update(extradict) diff --git a/mailman/pipeline/docs/ack-headers.txt b/mailman/pipeline/docs/ack-headers.txt index 28a8eed9e..ca41df03e 100644 --- a/mailman/pipeline/docs/ack-headers.txt +++ b/mailman/pipeline/docs/ack-headers.txt @@ -7,7 +7,6 @@ transformations. Some headers get added, others get changed. Some of these changes depend on mailing list settings and others depend on how the message is getting sent through the system. We'll take things one-by-one. - >>> from mailman.configuration import config >>> from mailman.pipeline.cook_headers import process >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.subject_prefix = u'' diff --git a/mailman/pipeline/docs/acknowledge.txt b/mailman/pipeline/docs/acknowledge.txt index 76c8fdf21..d1206b6f3 100644 --- a/mailman/pipeline/docs/acknowledge.txt +++ b/mailman/pipeline/docs/acknowledge.txt @@ -5,7 +5,6 @@ When a user posts a message to a mailing list, and that user has chosen to receive acknowledgments of their postings, Mailman will sent them such an acknowledgment. - >>> from mailman.configuration import config >>> handler = config.handlers['acknowledge'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.real_name = u'XTest' @@ -16,8 +15,7 @@ acknowledgment. >>> # Ensure that the virgin queue is empty, since we'll be checking this >>> # for new auto-response messages. - >>> from mailman.queue import Switchboard - >>> virginq = Switchboard(config.VIRGINQUEUE_DIR) + >>> virginq = config.switchboards['virgin'] >>> virginq.files [] diff --git a/mailman/pipeline/docs/after-delivery.txt b/mailman/pipeline/docs/after-delivery.txt index 5bc9b5936..b910e89a6 100644 --- a/mailman/pipeline/docs/after-delivery.txt +++ b/mailman/pipeline/docs/after-delivery.txt @@ -6,7 +6,6 @@ by the rest of the handlers in the incoming queue pipeline, a couple of bookkeeping pieces of information are updated. >>> import datetime - >>> from mailman.configuration import config >>> handler = config.handlers['after-delivery'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> post_time = datetime.datetime.now() - datetime.timedelta(minutes=10) diff --git a/mailman/pipeline/docs/archives.txt b/mailman/pipeline/docs/archives.txt index 67ad45c89..d81f6e27b 100644 --- a/mailman/pipeline/docs/archives.txt +++ b/mailman/pipeline/docs/archives.txt @@ -8,11 +8,9 @@ archivers to work in a separate process from the main Mailman delivery processes. >>> from mailman.app.lifecycle import create_list - >>> from mailman.configuration import config - >>> from mailman.queue import Switchboard >>> handler = config.handlers['to-archive'] >>> mlist = create_list(u'_xtest@example.com') - >>> switchboard = Switchboard(config.ARCHQUEUE_DIR) + >>> switchboard = config.switchboards['archive'] A helper function. diff --git a/mailman/pipeline/docs/avoid-duplicates.txt b/mailman/pipeline/docs/avoid-duplicates.txt index 9fd332d1b..e1d31716a 100644 --- a/mailman/pipeline/docs/avoid-duplicates.txt +++ b/mailman/pipeline/docs/avoid-duplicates.txt @@ -6,7 +6,6 @@ reduce the reception of duplicate messages. It does this by removing certain recipients from the list of recipients that earlier handler modules (e.g. CalcRecips) calculates. - >>> from mailman.configuration import config >>> handler = config.handlers['avoid-duplicates'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') diff --git a/mailman/pipeline/docs/calc-recips.txt b/mailman/pipeline/docs/calc-recips.txt index 057351873..550edff51 100644 --- a/mailman/pipeline/docs/calc-recips.txt +++ b/mailman/pipeline/docs/calc-recips.txt @@ -5,7 +5,6 @@ Every message that makes it through to the list membership gets sent to a set of recipient addresses. These addresses are calculated by one of the handler modules and depends on a host of factors. - >>> from mailman.configuration import config >>> handler = config.handlers['calculate-recipients'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') diff --git a/mailman/pipeline/docs/cleanse.txt b/mailman/pipeline/docs/cleanse.txt index 1597095b3..0940cdb4b 100644 --- a/mailman/pipeline/docs/cleanse.txt +++ b/mailman/pipeline/docs/cleanse.txt @@ -5,7 +5,6 @@ All messages posted to a list get their headers cleansed. Some headers are related to additional permissions that can be granted to the message and other headers can be used to fish for membership. - >>> from mailman.configuration import config >>> handler = config.handlers['cleanse'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') diff --git a/mailman/pipeline/docs/cook-headers.txt b/mailman/pipeline/docs/cook-headers.txt index 4fbdf58bb..985214079 100644 --- a/mailman/pipeline/docs/cook-headers.txt +++ b/mailman/pipeline/docs/cook-headers.txt @@ -8,7 +8,6 @@ changes depend on mailing list settings and others depend on how the message is getting sent through the system. We'll take things one-by-one. >>> from mailman.pipeline.cook_headers import process - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.subject_prefix = u'' >>> mlist.include_list_post_header = False diff --git a/mailman/pipeline/docs/decorate.txt b/mailman/pipeline/docs/decorate.txt index 60afb0170..b805e23cf 100644 --- a/mailman/pipeline/docs/decorate.txt +++ b/mailman/pipeline/docs/decorate.txt @@ -6,7 +6,6 @@ original message. A handler module takes care of this based on the settings of the mailing list and the type of message being processed. >>> from mailman.pipeline.decorate import process - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> msg_text = """\ ... From: aperson@example.org diff --git a/mailman/pipeline/docs/digests.txt b/mailman/pipeline/docs/digests.txt index df01379b9..1d7112fd5 100644 --- a/mailman/pipeline/docs/digests.txt +++ b/mailman/pipeline/docs/digests.txt @@ -7,15 +7,13 @@ digests, although only two are currently supported: MIME digests and RFC 1153 (a.k.a. plain text) digests. >>> from mailman.pipeline.to_digest import process - >>> from mailman.queue import Switchboard - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.preferred_language = u'en' >>> mlist.web_page_url = u'http://www.example.com/' >>> mlist.real_name = u'XTest' >>> mlist.subject_prefix = u'[_XTest] ' >>> mlist.one_last_digest = set() - >>> switchboard = Switchboard(config.VIRGINQUEUE_DIR) + >>> switchboard = config.switchboards['virgin'] This is a helper function used to iterate through all the accumulated digest messages, in the order in which they were posted. This makes it easier to @@ -407,11 +405,16 @@ When messages come in with a content-type character set different than that of the list's preferred language, recipients wil get an internationalized digest. French is not enabled by default site-wide, so enable that now. -XXX We also have to set the default server language to French, otherwise the -English template will be found and the masthead won't be translated. - >>> config.languages.enable_language('fr') - >>> config.DEFAULT_SERVER_LANGUAGE = u'fr' + + # Simulate the site administrator setting the default server language to + # French in the configuration file. Without this, the English template + # will be found and the masthead won't be translated. + >>> config.push('french', """ + ... [mailman] + ... default_language: fr + ... """) + >>> mlist.preferred_language = u'fr' >>> msg = message_from_string("""\ ... From: aperson@example.org diff --git a/mailman/pipeline/docs/file-recips.txt b/mailman/pipeline/docs/file-recips.txt index e93bba9aa..d006151ba 100644 --- a/mailman/pipeline/docs/file-recips.txt +++ b/mailman/pipeline/docs/file-recips.txt @@ -5,7 +5,6 @@ Mailman can calculate the recipients for a message from a Sendmail-style include file. This file must be called members.txt and it must live in the list's data directory. - >>> from mailman.configuration import config >>> handler = config.handlers['file-recipients'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') diff --git a/mailman/pipeline/docs/filtering.txt b/mailman/pipeline/docs/filtering.txt index c5dca1531..70ca3098d 100644 --- a/mailman/pipeline/docs/filtering.txt +++ b/mailman/pipeline/docs/filtering.txt @@ -7,7 +7,6 @@ message. It does this with the MimeDel handler module, although other handlers can potentially do other kinds of finer level content filtering. >>> from mailman.pipeline.mime_delete import process - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.preferred_language = u'en' diff --git a/mailman/pipeline/docs/nntp.txt b/mailman/pipeline/docs/nntp.txt index 5652d7924..0120de394 100644 --- a/mailman/pipeline/docs/nntp.txt +++ b/mailman/pipeline/docs/nntp.txt @@ -5,12 +5,10 @@ Mailman has an NNTP gateway, whereby messages posted to the mailing list can be forwarded onto an NNTP newsgroup. Typically this means Usenet, but since NNTP is to Usenet as IP is to the web, it's more general than that. - >>> from mailman.queue import Switchboard - >>> from mailman.configuration import config >>> handler = config.handlers['to-usenet'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.preferred_language = u'en' - >>> switchboard = Switchboard(config.NEWSQUEUE_DIR) + >>> switchboard = config.switchboards['news'] Gatewaying from the mailing list to the newsgroup happens through a separate 'nntp' queue and happen immediately when the message is posted through to the diff --git a/mailman/pipeline/docs/reply-to.txt b/mailman/pipeline/docs/reply-to.txt index ad9100ce1..570ffb7ea 100644 --- a/mailman/pipeline/docs/reply-to.txt +++ b/mailman/pipeline/docs/reply-to.txt @@ -8,7 +8,6 @@ changes depend on mailing list settings and others depend on how the message is getting sent through the system. We'll take things one-by-one. >>> from mailman.pipeline.cook_headers import process - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.subject_prefix = u'' diff --git a/mailman/pipeline/docs/replybot.txt b/mailman/pipeline/docs/replybot.txt index 2e3765cab..f9f824e4e 100644 --- a/mailman/pipeline/docs/replybot.txt +++ b/mailman/pipeline/docs/replybot.txt @@ -7,15 +7,13 @@ responses are subject to various conditions, such as headers in the original message or the amount of time since the last auto-response. >>> from mailman.pipeline.replybot import process - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.real_name = u'XTest' >>> mlist.web_page_url = u'http://www.example.com/' >>> # Ensure that the virgin queue is empty, since we'll be checking this >>> # for new auto-response messages. - >>> from mailman.queue import Switchboard - >>> virginq = Switchboard(config.VIRGINQUEUE_DIR) + >>> virginq = config.switchboards['virgin'] >>> virginq.files [] diff --git a/mailman/pipeline/docs/scrubber.txt b/mailman/pipeline/docs/scrubber.txt index 744925f34..eddd1939d 100644 --- a/mailman/pipeline/docs/scrubber.txt +++ b/mailman/pipeline/docs/scrubber.txt @@ -7,7 +7,6 @@ scrub attachments from messages so that binary goop doesn't end up in an archive message. >>> from mailman.pipeline.scrubber import process, save_attachment - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.preferred_language = u'en' @@ -51,7 +50,8 @@ filename suggested in the message's Content-Disposition: header or not. If enabled, the filename will be used when this header attribute is present (yes, this is an unfortunate double negative). - >>> config.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME = False + >>> from mailman import Defaults + >>> Defaults.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME = False >>> msg = message_from_string("""\ ... Content-Type: image/gif; name="xtest.gif" ... Content-Transfer-Encoding: base64 @@ -80,7 +80,7 @@ The site administrator can also configure Mailman to ignore the Content-Disposition: filename. This is the default for reasons described in the Defaults.py.in file. - >>> config.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME = True + >>> Defaults.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME = True >>> msg = message_from_string("""\ ... Content-Type: image/gif; name="xtest.gif" ... Content-Transfer-Encoding: base64 diff --git a/mailman/pipeline/docs/subject-munging.txt b/mailman/pipeline/docs/subject-munging.txt index 02677d6e2..b2972683b 100644 --- a/mailman/pipeline/docs/subject-munging.txt +++ b/mailman/pipeline/docs/subject-munging.txt @@ -8,7 +8,6 @@ changes depend on mailing list settings and others depend on how the message is getting sent through the system. We'll take things one-by-one. >>> from mailman.pipeline.cook_headers import process - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') >>> mlist.subject_prefix = u'' diff --git a/mailman/pipeline/docs/tagger.txt b/mailman/pipeline/docs/tagger.txt index 778f7cc73..9f0bcd4b2 100644 --- a/mailman/pipeline/docs/tagger.txt +++ b/mailman/pipeline/docs/tagger.txt @@ -9,8 +9,6 @@ its Subject: and Keywords: headers compared against these regular expressions. The message then gets tagged with the topic names of each hit. >>> from mailman.pipeline.tagger import process - >>> from mailman.queue import Switchboard - >>> from mailman.configuration import config >>> mlist = config.db.list_manager.create(u'_xtest@example.com') Topics must be enabled for Mailman to do any topic matching, even if topics diff --git a/mailman/pipeline/docs/to-outgoing.txt b/mailman/pipeline/docs/to-outgoing.txt index 3840b71ee..81e870e6c 100644 --- a/mailman/pipeline/docs/to-outgoing.txt +++ b/mailman/pipeline/docs/to-outgoing.txt @@ -9,11 +9,9 @@ term somewhat incorrectly, but within the spirit of the standard, which basically describes how to encode the recipient's address in the originator headers for unambigous bounce processing. - >>> from mailman.queue import Switchboard - >>> from mailman.configuration import config >>> handler = config.handlers['to-outgoing'] >>> mlist = config.db.list_manager.create(u'_xtest@example.com') - >>> switchboard = Switchboard(config.OUTQUEUE_DIR) + >>> switchboard = config.switchboards['out'] >>> def queue_size(): ... size = len(switchboard.files) @@ -67,8 +65,9 @@ option to VERP personalized deliveries is set, then the message will be VERP'd. # Save the original value for clean up. - >>> verp_personalized_delivieries = config.VERP_PERSONALIZED_DELIVERIES - >>> config.VERP_PERSONALIZED_DELIVERIES = True + >>> from mailman import Defaults + >>> verp_personalized_delivieries = Defaults.VERP_PERSONALIZED_DELIVERIES + >>> Defaults.VERP_PERSONALIZED_DELIVERIES = True >>> from mailman.interfaces import Personalization >>> mlist.personalize = Personalization.individual >>> msgdata = dict(foo=1, bar=2) @@ -81,7 +80,7 @@ VERP'd. However, if the global configuration variable prohibits VERP'ing, even personalized lists will not VERP. - >>> config.VERP_PERSONALIZED_DELIVERIES = False + >>> Defaults.VERP_PERSONALIZED_DELIVERIES = False >>> msgdata = dict(foo=1, bar=2) >>> handler.process(mlist, msg, msgdata) >>> print msgdata.get('verp') @@ -95,8 +94,8 @@ Mailman how often to VERP even non-personalized mailing lists. It can be set to zero, which means non-personalized messages will never be VERP'd. # Save the original value for clean up. - >>> verp_delivery_interval = config.VERP_DELIVERY_INTERVAL - >>> config.VERP_DELIVERY_INTERVAL = 0 + >>> verp_delivery_interval = Defaults.VERP_DELIVERY_INTERVAL + >>> Defaults.VERP_DELIVERY_INTERVAL = 0 >>> mlist.personalize = Personalization.none >>> msgdata = dict(foo=1, bar=2) >>> handler.process(mlist, msg, msgdata) @@ -107,7 +106,7 @@ to zero, which means non-personalized messages will never be VERP'd. If the interval is set to 1, then every message will be VERP'd. - >>> config.VERP_DELIVERY_INTERVAL = 1 + >>> Defaults.VERP_DELIVERY_INTERVAL = 1 >>> for i in range(10): ... msgdata = dict(foo=1, bar=2) ... handler.process(mlist, msg, msgdata) @@ -128,7 +127,7 @@ If the interval is set to 1, then every message will be VERP'd. If the interval is set to some other number, then one out of that many posts will be VERP'd. - >>> config.VERP_DELIVERY_INTERVAL = 3 + >>> Defaults.VERP_DELIVERY_INTERVAL = 3 >>> for i in range(10): ... mlist.post_id = i ... msgdata = dict(foo=1, bar=2) @@ -151,5 +150,5 @@ will be VERP'd. Clean up ======== - >>> config.VERP_PERSONALIZED_DELIVERIES = verp_personalized_delivieries - >>> config.VERP_DELIVERY_INTERVAL = verp_delivery_interval + >>> Defaults.VERP_PERSONALIZED_DELIVERIES = verp_personalized_delivieries + >>> Defaults.VERP_DELIVERY_INTERVAL = verp_delivery_interval diff --git a/mailman/pipeline/file_recipients.py b/mailman/pipeline/file_recipients.py index fd7ff0b69..75a00c14e 100644 --- a/mailman/pipeline/file_recipients.py +++ b/mailman/pipeline/file_recipients.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # diff --git a/mailman/pipeline/mime_delete.py b/mailman/pipeline/mime_delete.py index 9cb34297f..57d529112 100644 --- a/mailman/pipeline/mime_delete.py +++ b/mailman/pipeline/mime_delete.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2002-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -39,7 +39,7 @@ from zope.interface import implements from mailman.Message import UserNotification from mailman.Utils import oneline -from mailman.configuration import config +from mailman.config import config from mailman.core import errors from mailman.i18n import _ from mailman.interfaces import IHandler diff --git a/mailman/pipeline/moderate.py b/mailman/pipeline/moderate.py index 11471dd3a..ec0a555d8 100644 --- a/mailman/pipeline/moderate.py +++ b/mailman/pipeline/moderate.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -24,7 +24,7 @@ from email.MIMEText import MIMEText from mailman import Message from mailman import Utils -from mailman.configuration import config +from mailman.config import config from mailman.core import errors from mailman.i18n import _ diff --git a/mailman/pipeline/owner_recipients.py b/mailman/pipeline/owner_recipients.py index 592e9e127..046cac50c 100644 --- a/mailman/pipeline/owner_recipients.py +++ b/mailman/pipeline/owner_recipients.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # diff --git a/mailman/pipeline/replybot.py b/mailman/pipeline/replybot.py index 39f6cc058..e889e58af 100644 --- a/mailman/pipeline/replybot.py +++ b/mailman/pipeline/replybot.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # diff --git a/mailman/pipeline/scrubber.py b/mailman/pipeline/scrubber.py index 4b8d9f770..b8beb22ad 100644 --- a/mailman/pipeline/scrubber.py +++ b/mailman/pipeline/scrubber.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -38,8 +38,9 @@ from locknix.lockfile import Lock from mimetypes import guess_all_extensions from zope.interface import implements +from mailman import Defaults from mailman import Utils -from mailman.configuration import config +from mailman.config import config from mailman.core.errors import DiscardMessage from mailman.core.plugins import get_plugin from mailman.i18n import _ @@ -158,7 +159,7 @@ def replace_payload_by_text(msg, text, charset): def process(mlist, msg, msgdata=None): - sanitize = config.ARCHIVE_HTML_SANITIZER + sanitize = Defaults.ARCHIVE_HTML_SANITIZER outer = True if msgdata is None: msgdata = {} @@ -409,7 +410,7 @@ def save_attachment(mlist, msg, dir, filter_html=True): filename, fnext = os.path.splitext(filename) # For safety, we should confirm this is valid ext for content-type # but we can use fnext if we introduce fnext filtering - if config.SCRUBBER_USE_ATTACHMENT_FILENAME_EXTENSION: + if Defaults.SCRUBBER_USE_ATTACHMENT_FILENAME_EXTENSION: # HTML message doesn't have filename :-( ext = fnext or guess_extension(ctype, fnext) else: @@ -430,7 +431,7 @@ def save_attachment(mlist, msg, dir, filter_html=True): with Lock(os.path.join(fsdir, 'attachments.lock')): # Now base the filename on what's in the attachment, uniquifying it if # necessary. - if not filename or config.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME: + if not filename or Defaults.SCRUBBER_DONT_USE_ATTACHMENT_FILENAME: filebase = 'attachment' else: # Sanitize the filename given in the message headers @@ -475,7 +476,7 @@ def save_attachment(mlist, msg, dir, filter_html=True): try: fp.write(decodedpayload) fp.close() - cmd = config.ARCHIVE_HTML_SANITIZER % {'filename' : tmppath} + cmd = Defaults.ARCHIVE_HTML_SANITIZER % {'filename' : tmppath} progfp = os.popen(cmd, 'r') decodedpayload = progfp.read() status = progfp.close() diff --git a/mailman/pipeline/smtp_direct.py b/mailman/pipeline/smtp_direct.py index 7d9242417..051ba0096 100644 --- a/mailman/pipeline/smtp_direct.py +++ b/mailman/pipeline/smtp_direct.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -27,37 +27,35 @@ for a threaded implementation. """ __metaclass__ = type -__all__ = ['SMTPDirect'] +__all__ = [ + 'SMTPDirect', + ] import copy import time import email import socket -import string import logging import smtplib from email.Charset import Charset from email.Header import Header from email.Utils import formataddr +from string import Template from zope.interface import implements +from mailman import Defaults from mailman import Utils -from mailman.configuration import config +from mailman.config import config from mailman.core import errors from mailman.i18n import _ from mailman.interfaces import IHandler, Personalization DOT = '.' - -log = logging.getLogger('mailman.smtp') -flog = logging.getLogger('mailman.smtp-failure') -every_log = logging.getLogger('mailman.' + config.SMTP_LOG_EVERY_MESSAGE[0]) -success_log = logging.getLogger('mailman.' + config.SMTP_LOG_SUCCESS[0]) -refused_log = logging.getLogger('mailman.' + config.SMTP_LOG_REFUSED[0]) -failure_log = logging.getLogger('mailman.' + config.SMTP_LOG_EACH_FAILURE[0]) +COMMA = ',' +log = logging.getLogger('mailman.smtp') @@ -68,8 +66,11 @@ class Connection: def __connect(self): self.__conn = smtplib.SMTP() - self.__conn.connect(config.SMTPHOST, config.SMTPPORT) - self.__numsessions = config.SMTP_MAX_SESSIONS_PER_CONNECTION + host = config.mta.smtp_host + port = int(config.mta.smtp_port) + log.debug('Connecting to %s:%s', host, port) + self.__conn.connect(host, port) + self.__numsessions = Defaults.SMTP_MAX_SESSIONS_PER_CONNECTION def sendmail(self, envsender, recips, msgtext): if self.__conn is None: @@ -101,20 +102,6 @@ class Connection: -class MessageDict(dict): - def __init__(self, message, extras): - super(MessageDict, self).__init__() - for key, value in message.items(): - self[key.lower()] = value - self.update(extras) - - -class Template(string.Template): - # Allow dashes and # signs, in addition to the standard pattern. - idpattern = '[_a-z#-][_a-z0-9#-]*' - - - def process(mlist, msg, msgdata): recips = msgdata.get('recips') if not recips: @@ -139,10 +126,10 @@ def process(mlist, msg, msgdata): chunks = [[recip] for recip in recips] msgdata['personalize'] = 1 deliveryfunc = verpdeliver - elif config.SMTP_MAX_RCPTS <= 0: + elif Defaults.SMTP_MAX_RCPTS <= 0: chunks = [recips] else: - chunks = chunkify(recips, config.SMTP_MAX_RCPTS) + chunks = chunkify(recips, Defaults.SMTP_MAX_RCPTS) # See if this is an unshunted message for which some were undelivered if msgdata.has_key('undelivered'): chunks = msgdata['undelivered'] @@ -192,38 +179,39 @@ def process(mlist, msg, msgdata): msgdata['recips'] = origrecips # Log the successful post t1 = time.time() - substitutions = MessageDict(msg, { - 'time' : t1-t0, - 'size' : msg.original_size, - '#recips' : len(recips), - '#refused' : len(refused), - 'listname' : mlist.fqdn_listname, - 'sender' : origsender, - }) - if 'message-id' not in substitutions: - substitutions['message-id'] = 'n/a' - # We have to use the copy() method because extended call syntax requires a - # concrete dictionary object; it does not allow a generic mapping (XXX is - # this still true in Python 2.3?). - if config.SMTP_LOG_EVERY_MESSAGE: - template = Template(config.SMTP_LOG_EVERY_MESSAGE[1]) - every_log.info('%s', template.safe_substitute(substitutions)) - + substitutions = dict( + msgid = msg.get('message-id', 'n/a'), + listname = mlist.fqdn_listname, + sender = origsender, + recip = len(recips), + size = msg.original_size, + seconds = t1 - t0, + refused = len(refused), + smtpcode = 'n/a', + smtpmsg = 'n/a', + ) + # Log this message. + template = config.logging.smtp.every + if template != 'no': + template = Template(template) + log.info('%s', template.safe_substitute(substitutions)) if refused: - if config.SMTP_LOG_REFUSED: - template = Template(config.SMTP_LOG_REFUSED[1]) - refused_log.info('%s', template.safe_substitute(substitutions)) - - elif msgdata.get('tolist'): - # Log the successful post, but only if it really was a post to the - # mailing list. Don't log sends to the -owner, or -admin addrs. - # -request addrs should never get here. BAW: it may be useful to log - # the other messages, but in that case, we should probably have a - # separate configuration variable to control that. - if config.SMTP_LOG_SUCCESS: - template = Template(config.SMTP_LOG_SUCCESS[1]) - success_log.info('%s', template.safe_substitute(substitutions)) - + template = config.logging.smtp.refused + if template != 'no': + template = Template(template) + log.info('%s', template.safe_substitute(substitutions)) + else: + # Log the successful post, but if it was not destined to the mailing + # list (e.g. to the owner or admin), print the actual recipients + # instead of just the number. + if not msgdata.get('tolist'): + recips = msg.get_all('to', []) + recips.extend(msg.get_all('cc', [])) + substitutions['recips'] = COMMA.join(recips) + template = config.logging.smtp.success + if template != 'no': + template = Template(template) + log.info('%s', template.safe_substitute(substitutions)) # Process any failed deliveries. tempfailures = [] permfailures = [] @@ -244,14 +232,15 @@ def process(mlist, msg, msgdata): # Deal with persistent transient failures by queuing them up for # future delivery. TBD: this could generate lots of log entries! tempfailures.append(recip) - if config.SMTP_LOG_EACH_FAILURE: - substitutions.update({ - 'recipient' : recip, - 'failcode' : code, - 'failmsg' : smtpmsg, - }) - template = Template(config.SMTP_LOG_EACH_FAILURE[1]) - failure_log.info('%s', template.safe_substitute(substitutions)) + template = config.logging.smtp.failure + if template != 'no': + substitutions.update( + recip = recip, + smtpcode = code, + smtpmsg = smtpmsg, + ) + template = Template(template) + log.info('%s', template.safe_substitute(substitutions)) # Return the results if tempfailures or permfailures: raise errors.SomeRecipientsFailed(tempfailures, permfailures) @@ -331,7 +320,8 @@ def verpdeliver(mlist, msg, msgdata, envsender, failures, conn): 'mailbox': rmailbox, 'host' : DOT.join(rdomain), } - envsender = '%s@%s' % ((config.VERP_FORMAT % d), DOT.join(bdomain)) + envsender = '%s@%s' % ((Defaults.VERP_FORMAT % d), + DOT.join(bdomain)) if mlist.personalize == Personalization.full: # When fully personalizing, we want the To address to point to the # recipient, not to the mailing list @@ -393,10 +383,10 @@ def bulkdeliver(mlist, msg, msgdata, envsender, failures, conn): # Send the message refused = conn.sendmail(envsender, recips, msgtext) except smtplib.SMTPRecipientsRefused, e: - flog.error('%s recipients refused: %s', msgid, e) + log.error('%s recipients refused: %s', msgid, e) refused = e.recipients except smtplib.SMTPResponseException, e: - flog.error('%s SMTP session failure: %s, %s', + log.error('%s SMTP session failure: %s, %s', msgid, e.smtp_code, e.smtp_error) # If this was a permanent failure, don't add the recipients to the # refused, because we don't want them to be added to failures. @@ -412,7 +402,7 @@ def bulkdeliver(mlist, msg, msgdata, envsender, failures, conn): # MTA not responding, or other socket problems, or any other kind of # SMTPException. In that case, nothing got delivered, so treat this # as a temporary failure. - flog.error('%s low level smtp error: %s', msgid, e) + log.error('%s low level smtp error: %s', msgid, e) error = str(e) for r in recips: refused[r] = (-1, error) diff --git a/mailman/pipeline/tagger.py b/mailman/pipeline/tagger.py index 13ad7ba49..d631342d3 100644 --- a/mailman/pipeline/tagger.py +++ b/mailman/pipeline/tagger.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # diff --git a/mailman/pipeline/to_archive.py b/mailman/pipeline/to_archive.py index b693d8341..5c32be53d 100644 --- a/mailman/pipeline/to_archive.py +++ b/mailman/pipeline/to_archive.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -23,10 +23,9 @@ __all__ = ['ToArchive'] from zope.interface import implements -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.interfaces import IHandler -from mailman.queue import Switchboard @@ -48,7 +47,5 @@ class ToArchive: # presence. I'm keeping "X-Archive: no" for backwards compatibility. if 'x-no-archive' in msg or msg.get('x-archive', '').lower() == 'no': return - # Send the message to the archiver queue - archq = Switchboard(config.ARCHQUEUE_DIR) - # Send the message to the queue - archq.enqueue(msg, msgdata) + # Send the message to the archiver queue. + config.switchboards['archive'].enqueue(msg, msgdata) diff --git a/mailman/pipeline/to_digest.py b/mailman/pipeline/to_digest.py index cec2fa1fc..96bfcdf47 100644 --- a/mailman/pipeline/to_digest.py +++ b/mailman/pipeline/to_digest.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -48,17 +48,17 @@ from email.parser import Parser from email.utils import formatdate, getaddresses, make_msgid from zope.interface import implements +from mailman import Defaults from mailman import Message from mailman import Utils from mailman import i18n from mailman.Mailbox import Mailbox from mailman.Mailbox import Mailbox -from mailman.configuration import config +from mailman.config import config from mailman.core import errors from mailman.interfaces import DeliveryMode, DeliveryStatus, IHandler from mailman.pipeline.decorate import decorate from mailman.pipeline.scrubber import process as scrubber -from mailman.queue import Switchboard _ = i18n._ @@ -268,8 +268,8 @@ def send_i18n_digests(mlist, mboxfp): # for the specific MIME or plain digests. keeper = {} all_keepers = {} - for header in (config.MIME_DIGEST_KEEP_HEADERS + - config.PLAIN_DIGEST_KEEP_HEADERS): + for header in (Defaults.MIME_DIGEST_KEEP_HEADERS + + Defaults.PLAIN_DIGEST_KEEP_HEADERS): all_keepers[header] = True all_keepers = all_keepers.keys() for keep in all_keepers: @@ -325,7 +325,7 @@ def send_i18n_digests(mlist, mboxfp): print >> plainmsg, _('[Message discarded by content filter]') continue # Honor the default setting - for h in config.PLAIN_DIGEST_KEEP_HEADERS: + for h in Defaults.PLAIN_DIGEST_KEEP_HEADERS: if msg[h]: uh = Utils.wrap('%s: %s' % (h, Utils.oneline(msg[h], in_unicode=True))) @@ -378,7 +378,7 @@ def send_i18n_digests(mlist, mboxfp): # Do our final bit of housekeeping, and then send each message to the # outgoing queue for delivery. mlist.next_digest_number += 1 - virginq = Switchboard(config.VIRGINQUEUE_DIR) + virginq = config.switchboards['virgin'] # Calculate the recipients lists plainrecips = set() mimerecips = set() diff --git a/mailman/pipeline/to_outgoing.py b/mailman/pipeline/to_outgoing.py index 48633da96..fdf201793 100644 --- a/mailman/pipeline/to_outgoing.py +++ b/mailman/pipeline/to_outgoing.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -28,10 +28,10 @@ __all__ = ['ToOutgoing'] from zope.interface import implements -from mailman.configuration import config +from mailman import Defaults +from mailman.config import config from mailman.i18n import _ from mailman.interfaces import IHandler, Personalization -from mailman.queue import Switchboard @@ -45,7 +45,7 @@ class ToOutgoing: def process(self, mlist, msg, msgdata): """See `IHandler`.""" - interval = config.VERP_DELIVERY_INTERVAL + interval = Defaults.VERP_DELIVERY_INTERVAL # Should we VERP this message? If personalization is enabled for this # list and VERP_PERSONALIZED_DELIVERIES is true, then yes we VERP it. # Also, if personalization is /not/ enabled, but @@ -57,7 +57,7 @@ class ToOutgoing: if 'verp' in msgdata: pass elif mlist.personalize <> Personalization.none: - if config.VERP_PERSONALIZED_DELIVERIES: + if Defaults.VERP_PERSONALIZED_DELIVERIES: msgdata['verp'] = True elif interval == 0: # Never VERP @@ -69,5 +69,5 @@ class ToOutgoing: # VERP every `interval' number of times msgdata['verp'] = not (int(mlist.post_id) % interval) # And now drop the message in qfiles/out - outq = Switchboard(config.OUTQUEUE_DIR) - outq.enqueue(msg, msgdata, listname=mlist.fqdn_listname) + config.switchboards['out'].enqueue( + msg, msgdata, listname=mlist.fqdn_listname) diff --git a/mailman/pipeline/to_usenet.py b/mailman/pipeline/to_usenet.py index 4ebd94bec..08e785d54 100644 --- a/mailman/pipeline/to_usenet.py +++ b/mailman/pipeline/to_usenet.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2008 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -25,10 +25,9 @@ import logging from zope.interface import implements -from mailman.configuration import config +from mailman.config import config from mailman.i18n import _ from mailman.interfaces import IHandler -from mailman.queue import Switchboard COMMASPACE = ', ' @@ -62,5 +61,5 @@ class ToUsenet: COMMASPACE.join(error)) return # Put the message in the news runner's queue - newsq = Switchboard(config.NEWSQUEUE_DIR) - newsq.enqueue(msg, msgdata, listname=mlist.fqdn_listname) + config.switchboards['news'].enqueue( + msg, msgdata, listname=mlist.fqdn_listname) |
