diff options
| author | Barry Warsaw | 2009-12-10 22:32:25 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-12-10 22:32:25 -0500 |
| commit | 8938d65327611dded72c7876ffe52e4d4d12ce76 (patch) | |
| tree | 7e2d5c354dd53f1d3f8c42b4a11a9b58b2c2fcb1 /src/mailman/queue | |
| parent | fbc81f61609ce0504245934d9bed0690fbd331a7 (diff) | |
| download | mailman-8938d65327611dded72c7876ffe52e4d4d12ce76.tar.gz mailman-8938d65327611dded72c7876ffe52e4d4d12ce76.tar.zst mailman-8938d65327611dded72c7876ffe52e4d4d12ce76.zip | |
* Refactor the language manager off of the config object and into a utility.
* Fix a few small typos in exception handlers.
* Move the initialization of the Zope Component Architecture into the first
initialization step. The only reason we couldn't do that previously was
because the domain object referenced the config, causing a circularity
problem. Refactor the Domain implementation to avoid that.
Diffstat (limited to 'src/mailman/queue')
| -rw-r--r-- | src/mailman/queue/__init__.py | 19 | ||||
| -rw-r--r-- | src/mailman/queue/command.py | 10 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/mailman/queue/__init__.py b/src/mailman/queue/__init__.py index a6d930c9d..4d9053ac3 100644 --- a/src/mailman/queue/__init__.py +++ b/src/mailman/queue/__init__.py @@ -53,6 +53,7 @@ from zope.interface import implements from mailman.config import config from mailman.core.i18n import _ from mailman.email.message import Message +from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.listmanager import IListManager from mailman.interfaces.runner import IRunner from mailman.interfaces.switchboard import ISwitchboard @@ -421,11 +422,16 @@ class Runner: # them out of our sight. # # Find out which mailing list this message is destined for. - listname = unicode(msgdata.get('listname')) - mlist = getUtility(IListManager).get(listname) + missing = object() + listname = msgdata.get('listname', missing) + mlist = (None + if listname is missing + else getUtility(IListManager).get(unicode(listname))) if mlist is None: - elog.error('Dequeuing message destined for missing list: %s', - listname) + elog.error( + '%s runner "%s" shunting message for missing list: %s', + msg['message-id'], self.name, + ('n/a' if listname is missing else listname)) config.switchboards['shunt'].enqueue(msg, msgdata) return # Now process this message. We also want to set up the language @@ -434,7 +440,10 @@ class Runner: # will be the list's preferred language. However, we must take # special care to reset the defaults, otherwise subsequent messages # may be translated incorrectly. - if msg.sender: + if mlist is None: + language_manager = getUtility(ILanguageManager) + language = language_manager[config.mailman.default_language] + elif msg.sender: member = mlist.members.get_member(msg.sender) language = (member.preferred_language if member is not None diff --git a/src/mailman/queue/command.py b/src/mailman/queue/command.py index d5ce708b1..401730e73 100644 --- a/src/mailman/queue/command.py +++ b/src/mailman/queue/command.py @@ -32,15 +32,17 @@ import re import logging from StringIO import StringIO -from email.Errors import HeaderParseError -from email.Header import decode_header, make_header -from email.Iterators import typed_subpart_iterator +from email.errors import HeaderParseError +from email.header import decode_header, make_header +from email.iterators import typed_subpart_iterator +from zope.component import getUtility from zope.interface import implements from mailman.config import config from mailman.core.i18n import _ from mailman.email.message import Message, UserNotification from mailman.interfaces.command import ContinueProcessing, IEmailResults +from mailman.interfaces.languages import ILanguageManager from mailman.queue import Runner @@ -198,7 +200,7 @@ class CommandRunner(Runner): # Send a reply, but do not attach the original message. This is a # compromise because the original message is often helpful in tracking # down problems, but it's also a vector for backscatter spam. - language = config.languages[msgdata['lang']] + language = getUtility(ILanguageManager)[msgdata['lang']] reply = UserNotification(msg.sender, mlist.bounces_address, _('The results of your email commands'), lang=language) |
