summaryrefslogtreecommitdiff
path: root/mailman/pipeline
diff options
context:
space:
mode:
Diffstat (limited to 'mailman/pipeline')
-rw-r--r--mailman/pipeline/cleanse_dkim.py4
-rw-r--r--mailman/pipeline/decorate.py3
-rw-r--r--mailman/pipeline/docs/acknowledge.txt3
-rw-r--r--mailman/pipeline/docs/archives.txt3
-rw-r--r--mailman/pipeline/docs/digests.txt16
-rw-r--r--mailman/pipeline/docs/nntp.txt3
-rw-r--r--mailman/pipeline/docs/replybot.txt3
-rw-r--r--mailman/pipeline/docs/tagger.txt1
-rw-r--r--mailman/pipeline/docs/to-outgoing.txt3
-rw-r--r--mailman/pipeline/scrubber.py12
-rw-r--r--mailman/pipeline/to_archive.py7
-rw-r--r--mailman/pipeline/to_digest.py10
-rw-r--r--mailman/pipeline/to_outgoing.py10
13 files changed, 37 insertions, 41 deletions
diff --git a/mailman/pipeline/cleanse_dkim.py b/mailman/pipeline/cleanse_dkim.py
index bc76e2726..3f3be98f8 100644
--- a/mailman/pipeline/cleanse_dkim.py
+++ b/mailman/pipeline/cleanse_dkim.py
@@ -31,7 +31,7 @@ __all__ = ['CleanseDKIM']
from zope.interface import implements
-from mailman.config 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/decorate.py b/mailman/pipeline/decorate.py
index bc684a1b1..f150d6d0c 100644
--- a/mailman/pipeline/decorate.py
+++ b/mailman/pipeline/decorate.py
@@ -28,6 +28,7 @@ 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.config import config
@@ -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/acknowledge.txt b/mailman/pipeline/docs/acknowledge.txt
index ccbb70e79..d1206b6f3 100644
--- a/mailman/pipeline/docs/acknowledge.txt
+++ b/mailman/pipeline/docs/acknowledge.txt
@@ -15,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/archives.txt b/mailman/pipeline/docs/archives.txt
index 9595a36e0..d81f6e27b 100644
--- a/mailman/pipeline/docs/archives.txt
+++ b/mailman/pipeline/docs/archives.txt
@@ -8,10 +8,9 @@ archivers to work in a separate process from the main Mailman delivery
processes.
>>> from mailman.app.lifecycle import create_list
- >>> 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/digests.txt b/mailman/pipeline/docs/digests.txt
index f478c1ec0..1d7112fd5 100644
--- a/mailman/pipeline/docs/digests.txt
+++ b/mailman/pipeline/docs/digests.txt
@@ -7,14 +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
>>> 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
@@ -406,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/nntp.txt b/mailman/pipeline/docs/nntp.txt
index 3ef3b2413..0120de394 100644
--- a/mailman/pipeline/docs/nntp.txt
+++ b/mailman/pipeline/docs/nntp.txt
@@ -5,11 +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
>>> 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/replybot.txt b/mailman/pipeline/docs/replybot.txt
index 7325417ed..f9f824e4e 100644
--- a/mailman/pipeline/docs/replybot.txt
+++ b/mailman/pipeline/docs/replybot.txt
@@ -13,8 +13,7 @@ message or the amount of time since the last auto-response.
>>> # 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/tagger.txt b/mailman/pipeline/docs/tagger.txt
index 64996755b..9f0bcd4b2 100644
--- a/mailman/pipeline/docs/tagger.txt
+++ b/mailman/pipeline/docs/tagger.txt
@@ -9,7 +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
>>> 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 70f93cfae..046ed9be8 100644
--- a/mailman/pipeline/docs/to-outgoing.txt
+++ b/mailman/pipeline/docs/to-outgoing.txt
@@ -9,10 +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
>>> 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)
diff --git a/mailman/pipeline/scrubber.py b/mailman/pipeline/scrubber.py
index abc904613..e8268f0cf 100644
--- a/mailman/pipeline/scrubber.py
+++ b/mailman/pipeline/scrubber.py
@@ -38,8 +38,8 @@ 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.config import config
from mailman.core.errors import DiscardMessage
from mailman.core.plugins import get_plugin
from mailman.i18n import _
@@ -158,7 +158,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 = {}
@@ -394,7 +394,7 @@ def makedirs(dir):
def save_attachment(mlist, msg, dir, filter_html=True):
- fsdir = os.path.join(config.PRIVATE_ARCHIVE_FILE_DIR,
+ fsdir = os.path.join(Defaults.PRIVATE_ARCHIVE_FILE_DIR,
mlist.fqdn_listname, dir)
makedirs(fsdir)
# Figure out the attachment type and get the decoded data
@@ -409,7 +409,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 +430,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 +475,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/to_archive.py b/mailman/pipeline/to_archive.py
index 4d8c27cf1..6ecb860c2 100644
--- a/mailman/pipeline/to_archive.py
+++ b/mailman/pipeline/to_archive.py
@@ -26,7 +26,6 @@ from zope.interface import implements
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 78984c92e..42f92df4e 100644
--- a/mailman/pipeline/to_digest.py
+++ b/mailman/pipeline/to_digest.py
@@ -48,6 +48,7 @@ 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
@@ -58,7 +59,6 @@ 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 d8d1ec935..bbaf43301 100644
--- a/mailman/pipeline/to_outgoing.py
+++ b/mailman/pipeline/to_outgoing.py
@@ -28,10 +28,10 @@ __all__ = ['ToOutgoing']
from zope.interface import implements
+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)