diff options
| author | bwarsaw | 2001-03-02 00:56:51 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-03-02 00:56:51 +0000 |
| commit | cbd1b5d3e5833051b9c8d166f89bfdda76bf8bd3 (patch) | |
| tree | 1553b53ae3f11a2c27dd298262f790a3705654f8 /Mailman/Queue/Runner.py | |
| parent | 36012989e9c1bda2cb0b2a1ef0f23bb5ab1d4027 (diff) | |
| download | mailman-cbd1b5d3e5833051b9c8d166f89bfdda76bf8bd3.tar.gz mailman-cbd1b5d3e5833051b9c8d166f89bfdda76bf8bd3.tar.zst mailman-cbd1b5d3e5833051b9c8d166f89bfdda76bf8bd3.zip | |
__onefile(): The qrunner framework now sets up the language context
for each processed message. It does this by getting the preferred
language of the sender of the message (defaulting to the list's
preferred language if the sender isn't a member of the list).
Next, it saves the previous global language context in a local
variable, sets the context to the message's preferred language and
disposes of the message. Then it restores the original language
context.
It also sets the message's metadata (key: `lang') to contain the
language name for the language context in case any handler modules
need access to it.
Diffstat (limited to 'Mailman/Queue/Runner.py')
| -rw-r--r-- | Mailman/Queue/Runner.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Mailman/Queue/Runner.py b/Mailman/Queue/Runner.py index cf766f807..c896fb4c4 100644 --- a/Mailman/Queue/Runner.py +++ b/Mailman/Queue/Runner.py @@ -25,6 +25,7 @@ from Mailman import mm_cfg from Mailman import Utils from Mailman import Errors from Mailman import MailList +from Mailman import i18n from Mailman.pythonlib.StringIO import StringIO from Mailman.Queue.Switchboard import Switchboard @@ -121,7 +122,23 @@ class Runner: return # Now process this message, keeping track of any subprocesses that may # have been spawned. We'll reap those later. - keepqueued = self._dispose(mlist, msg, msgdata) + # + # We also want to set up the language context for this message. The + # context will be the preferred language for the user if a member of + # the list, or the list's preferred language. However, we must take + # special care to reset the defaults, otherwise subsequent messages + # may be translated incorrectly. BAW: I'm not sure I like this + # approach, but I can't think of anything better right now. + otranslation = i18n.get_translation() + sender = msg.get_sender() + lang = mlist.GetPreferredLanguage(sender) + i18n.set_language(lang) + msgdata['lang'] = lang + try: + keepqueued = self._dispose(mlist, msg, msgdata) + finally: + i18n.set_translation(otranslation) + # Keep tabs on any child processes that got spawned. kids = msgdata.get('_kids') if kids: self._kids.update(kids) |
