summaryrefslogtreecommitdiff
path: root/src/mailman/queue/__init__.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-12-10 22:32:25 -0500
committerBarry Warsaw2009-12-10 22:32:25 -0500
commit8938d65327611dded72c7876ffe52e4d4d12ce76 (patch)
tree7e2d5c354dd53f1d3f8c42b4a11a9b58b2c2fcb1 /src/mailman/queue/__init__.py
parentfbc81f61609ce0504245934d9bed0690fbd331a7 (diff)
downloadmailman-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/__init__.py')
-rw-r--r--src/mailman/queue/__init__.py19
1 files changed, 14 insertions, 5 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