diff options
| author | Barry Warsaw | 2009-02-09 22:19:18 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-02-09 22:19:18 -0500 |
| commit | 98c52ea14883f0261fd7a2f2fe8db42d96331ddb (patch) | |
| tree | a0c5817f4c226ed14b3fe510314e825980b6cb4e /src/mailman/app | |
| parent | 84a81e4a90349f7116863d2f45cda1ee31b5b3b5 (diff) | |
| download | mailman-98c52ea14883f0261fd7a2f2fe8db42d96331ddb.tar.gz mailman-98c52ea14883f0261fd7a2f2fe8db42d96331ddb.tar.zst mailman-98c52ea14883f0261fd7a2f2fe8db42d96331ddb.zip | |
Move mailman.Message to mailman.email.Message. Rename Message.get_sender() to
Message.sender (property) and Message.get_senders() to Message.senders
(another property). The semantics of .sender is slightly different too; it no
longer consults config.mailman.use_envelope_sender.
Add absolute_import and unicode_literals to Utils.py, and clean up a few
imports.
Diffstat (limited to 'src/mailman/app')
| -rw-r--r-- | src/mailman/app/bounces.py | 15 | ||||
| -rw-r--r-- | src/mailman/app/membership.py | 4 | ||||
| -rw-r--r-- | src/mailman/app/moderator.py | 16 | ||||
| -rw-r--r-- | src/mailman/app/notifications.py | 8 | ||||
| -rw-r--r-- | src/mailman/app/registrar.py | 2 |
5 files changed, 23 insertions, 22 deletions
diff --git a/src/mailman/app/bounces.py b/src/mailman/app/bounces.py index 875f615a5..aa7f51c77 100644 --- a/src/mailman/app/bounces.py +++ b/src/mailman/app/bounces.py @@ -17,7 +17,7 @@ """Application level bounce handling.""" -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals __metaclass__ = type __all__ = [ @@ -29,8 +29,8 @@ import logging from email.mime.message import MIMEMessage from email.mime.text import MIMEText -from mailman import Message from mailman import Utils +from mailman.email.message import Message, UserNotification from mailman.i18n import _ log = logging.getLogger('mailman.config') @@ -40,7 +40,10 @@ log = logging.getLogger('mailman.config') def bounce_message(mlist, msg, e=None): # Bounce a message back to the sender, with an error message if provided # in the exception argument. - sender = msg.get_sender() + if msg.sender is None: + # We can't bounce the message if we don't know who it's supposed to go + # to. + return subject = msg.get('subject', _('(no subject)')) subject = Utils.oneline(subject, Utils.GetCharSet(mlist.preferred_language)) @@ -49,10 +52,8 @@ def bounce_message(mlist, msg, e=None): else: notice = _(e.notice) # Currently we always craft bounces as MIME messages. - bmsg = Message.UserNotification(msg.get_sender(), - mlist.owner_address, - subject, - lang=mlist.preferred_language) + bmsg = UserNotification(msg.sender, mlist.owner_address, subject, + lang=mlist.preferred_language) # BAW: Be sure you set the type before trying to attach, or you'll get # a MultipartConversionError. bmsg.set_type('multipart/mixed') diff --git a/src/mailman/app/membership.py b/src/mailman/app/membership.py index 4b9609469..79e2501bd 100644 --- a/src/mailman/app/membership.py +++ b/src/mailman/app/membership.py @@ -28,12 +28,12 @@ __all__ = [ from email.utils import formataddr -from mailman import Message from mailman import Utils from mailman import i18n from mailman.app.notifications import send_goodbye_message from mailman.config import config from mailman.core import errors +from mailman.email.message import Message, OwnerNotification from mailman.interfaces.member import AlreadySubscribedError, MemberRole _ = i18n._ @@ -133,5 +133,5 @@ def delete_member(mlist, address, admin_notif=None, userack=None): {'listname': mlist.real_name, 'member' : formataddr((realname, address)), }, mlist=mlist) - msg = Message.OwnerNotification(mlist, subject, text) + msg = OwnerNotification(mlist, subject, text) msg.send(mlist) diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py index b40a34344..1f66e00ac 100644 --- a/src/mailman/app/moderator.py +++ b/src/mailman/app/moderator.py @@ -17,7 +17,7 @@ """Application support for moderators.""" -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals __metaclass__ = type __all__ = [ @@ -34,7 +34,6 @@ import logging from datetime import datetime from email.utils import formataddr, formatdate, getaddresses, make_msgid -from mailman import Message from mailman import Utils from mailman import i18n from mailman.app.membership import add_member, delete_member @@ -42,10 +41,12 @@ from mailman.app.notifications import ( send_admin_subscription_notice, send_welcome_message) from mailman.config import config from mailman.core import errors +from mailman.email.message import Message, UserNotification from mailman.interfaces import Action from mailman.interfaces.member import AlreadySubscribedError, DeliveryMode from mailman.interfaces.requests import RequestType + _ = i18n._ vlog = logging.getLogger('mailman.vette') @@ -87,7 +88,7 @@ def hold_message(mlist, msg, msgdata=None, reason=None): # the moderation interface. msgdata['_mod_message_id'] = message_id msgdata['_mod_fqdn_listname'] = mlist.fqdn_listname - msgdata['_mod_sender'] = msg.get_sender() + msgdata['_mod_sender'] = msg.sender msgdata['_mod_subject'] = msg.get('subject', _('(no subject)')) msgdata['_mod_reason'] = reason msgdata['_mod_hold_date'] = datetime.now().isoformat() @@ -165,7 +166,7 @@ def handle_message(mlist, id, action, if member: language = member.preferred_language with i18n.using_language(language): - fmsg = Message.UserNotification( + fmsg = UserNotification( addresses, mlist.bounces_address, _('Forward of moderated message'), lang=language) @@ -212,7 +213,7 @@ def hold_subscription(mlist, address, realname, password, mode, language): }, mlist=mlist) # This message should appear to come from the <list>-owner so as # to avoid any useless bounce processing. - msg = Message.UserNotification( + msg = UserNotification( mlist.owner_address, mlist.owner_address, subject, text, mlist.preferred_language) msg.send(mlist, tomoderators=True) @@ -284,7 +285,7 @@ def hold_unsubscription(mlist, address): }, mlist=mlist) # This message should appear to come from the <list>-owner so as # to avoid any useless bounce processing. - msg = Message.UserNotification( + msg = UserNotification( mlist.owner_address, mlist.owner_address, subject, text, mlist.preferred_language) msg.send(mlist, tomoderators=True) @@ -346,6 +347,5 @@ def _refuse(mlist, request, recip, comment, origmsg=None, lang=None): str(origmsg) ]) subject = _('Request to mailing list "$realname" rejected') - msg = Message.UserNotification(recip, mlist.bounces_address, - subject, text, lang) + msg = UserNotification(recip, mlist.bounces_address, subject, text, lang) msg.send(mlist) diff --git a/src/mailman/app/notifications.py b/src/mailman/app/notifications.py index 9bef9998b..b1d77dc6f 100644 --- a/src/mailman/app/notifications.py +++ b/src/mailman/app/notifications.py @@ -30,10 +30,10 @@ __all__ = [ from email.utils import formataddr from lazr.config import as_boolean -from mailman import Message from mailman import Utils from mailman import i18n from mailman.config import config +from mailman.email.message import Message, OwnerNotification, UserNotification from mailman.interfaces.member import DeliveryMode @@ -78,7 +78,7 @@ def send_welcome_message(mlist, address, language, delivery_mode, text=''): digmode = _(' (Digest mode)') else: digmode = '' - msg = Message.UserNotification( + msg = UserNotification( address, mlist.request_address, _('Welcome to the "$mlist.real_name" mailing list${digmode}'), text, language) @@ -104,7 +104,7 @@ def send_goodbye_message(mlist, address, language): goodbye = Utils.wrap(mlist.goodbye_msg) + '\n' else: goodbye = '' - msg = Message.UserNotification( + msg = UserNotification( address, mlist.bounces_address, _('You have been unsubscribed from the $mlist.real_name mailing list'), goodbye, language) @@ -132,5 +132,5 @@ def send_admin_subscription_notice(mlist, address, full_name, language): {'listname' : mlist.real_name, 'member' : formataddr((full_name, address)), }, mlist=mlist) - msg = Message.OwnerNotification(mlist, subject, text) + msg = OwnerNotification(mlist, subject, text) msg.send(mlist) diff --git a/src/mailman/app/registrar.py b/src/mailman/app/registrar.py index 6a2abeba9..654106668 100644 --- a/src/mailman/app/registrar.py +++ b/src/mailman/app/registrar.py @@ -31,9 +31,9 @@ import datetime from pkg_resources import resource_string from zope.interface import implements -from mailman.Message import UserNotification from mailman.Utils import ValidateEmail from mailman.config import config +from mailman.email.message import UserNotification from mailman.i18n import _ from mailman.interfaces.domain import IDomain from mailman.interfaces.member import MemberRole |
