diff options
| author | Barry Warsaw | 2009-12-12 17:03:30 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-12-12 17:03:30 -0500 |
| commit | 725ebe36e2548c5da711087640bd423181411241 (patch) | |
| tree | 8aae553f5b05d3889511dcbce8dd92f3fa7c469e /src/mailman/commands | |
| parent | 3c4c8f9c383b6e92e0a9a970079b296a4ac30e88 (diff) | |
| download | mailman-725ebe36e2548c5da711087640bd423181411241.tar.gz mailman-725ebe36e2548c5da711087640bd423181411241.tar.zst mailman-725ebe36e2548c5da711087640bd423181411241.zip | |
IRegistrar is now a utility; it doesn't need to be adapted from an IDomain.
This is because registration confirmation messages must come from the mailing
list that the subscription request came from.
Remove IDomain.confirm_address() since this lives only on the IMailingList now.
Diffstat (limited to 'src/mailman/commands')
| -rw-r--r-- | src/mailman/commands/docs/membership.txt | 130 | ||||
| -rw-r--r-- | src/mailman/commands/eml_confirm.py | 3 | ||||
| -rw-r--r-- | src/mailman/commands/eml_membership.py | 3 |
3 files changed, 88 insertions, 48 deletions
diff --git a/src/mailman/commands/docs/membership.txt b/src/mailman/commands/docs/membership.txt index b91dd17f1..a0af15ba7 100644 --- a/src/mailman/commands/docs/membership.txt +++ b/src/mailman/commands/docs/membership.txt @@ -1,14 +1,23 @@ -================== -The 'join' command -================== +============================ +Membership changes via email +============================ + +Membership changes such as joining and leaving a mailing list, can be effected +via the email interface. The Mailman email commands 'join', 'leave', and +'confirm' are used. + + +Joining a mailing list +====================== The mail command 'join' subscribes an email address to the mailing list. 'subscribe' is an alias for 'join'. - >>> command = config.commands['join'] - >>> print command.name + >>> from mailman.commands.eml_membership import Join + >>> join = Join() + >>> print join.name join - >>> print command.description + >>> print join.description Join this mailing list. You will be asked to confirm your subscription request and you may be issued a provisional password. <BLANKLINE> @@ -19,22 +28,23 @@ The mail command 'join' subscribes an email address to the mailing list. <BLANKLINE> join address=myotheraddress@example.com <BLANKLINE> - >>> print command.argument_description + >>> print join.argument_description [digest=<yes|no>] [address=<address>] No address to join -================== +------------------ - >>> from mailman.email.message import Message - >>> from mailman.queue.command import Results >>> mlist = create_list('alpha@example.com') When no address argument is given, the message's From address will be used. If that's missing though, then an error is returned. + >>> from mailman.queue.command import Results >>> results = Results() - >>> print command.process(mlist, Message(), {}, (), results) + + >>> from mailman.email.message import Message + >>> print join.process(mlist, Message(), {}, (), results) ContinueProcessing.no >>> print unicode(results) The results of your email command are provided below. @@ -44,7 +54,8 @@ If that's missing though, then an error is returned. The 'subscribe' command is an alias. - >>> subscribe = config.commands['subscribe'] + >>> from mailman.commands.eml_membership import Subscribe + >>> subscribe = Subscribe() >>> print subscribe.name subscribe >>> results = Results() @@ -58,7 +69,7 @@ The 'subscribe' command is an alias. Joining the sender -================== +------------------ When the message has a From field, that address will be subscribed. @@ -67,7 +78,7 @@ When the message has a From field, that address will be subscribed. ... ... """) >>> results = Results() - >>> print command.process(mlist, msg, {}, (), results) + >>> print join.process(mlist, msg, {}, (), results) ContinueProcessing.yes >>> print unicode(results) The results of your email command are provided below. @@ -86,13 +97,15 @@ first. Mailman has sent her the confirmation message. - >>> virginq = config.switchboards['virgin'] - >>> qmsg, qdata = virginq.dequeue(virginq.files[0]) - >>> print qmsg.as_string() + >>> from mailman.testing.helpers import get_queue_messages + >>> items = get_queue_messages('virgin') + >>> len(items) + 1 + >>> print items[0].msg.as_string() MIME-Version: 1.0 ... Subject: confirm ... - From: confirm-...@example.com + From: alpha-confirm+...@example.com To: anne@example.com ... <BLANKLINE> @@ -121,12 +134,27 @@ Mailman has sent her the confirmation message. Once Anne confirms her registration, she will be made a member of the mailing list. - >>> token = str(qmsg['subject']).split()[1].strip() - >>> from mailman.interfaces.domain import IDomainManager - >>> from mailman.interfaces.registrar import IRegistrar - >>> registrar = IRegistrar(getUtility(IDomainManager)['example.com']) - >>> registrar.confirm(token) - True + >>> def extract_token(message): + ... return str(message['subject']).split()[1].strip() + >>> token = extract_token(items[0].msg) + + >>> from mailman.commands.eml_confirm import Confirm + >>> confirm = Confirm() + >>> msg = message_from_string("""\ + ... To: alpha-confirm+{token}@example.com + ... From: anne@example.com + ... Subject: Re: confirm {token} + ... + ... """.format(token=token)) + + >>> results = Results() + >>> print confirm.process(mlist, msg, {}, (token,), results) + ContinueProcessing.yes + >>> print unicode(results) + The results of your email command are provided below. + <BLANKLINE> + Confirmed + <BLANKLINE> >>> user = user_manager.get_user('anne@example.com') >>> print user.real_name @@ -142,14 +170,14 @@ Anne is also now a member of the mailing list. Joining a second list -===================== +--------------------- >>> mlist_2 = create_list('baker@example.com') >>> msg = message_from_string("""\ ... From: Anne Person <anne@example.com> ... ... """) - >>> print command.process(mlist_2, msg, {}, (), Results()) + >>> print join.process(mlist_2, msg, {}, (), Results()) ContinueProcessing.yes Anne of course, is still registered. @@ -164,10 +192,25 @@ But she is not a member of the mailing list. One Anne confirms this subscription, she becomes a member of the mailing list. - >>> qmsg, qdata = virginq.dequeue(virginq.files[0]) - >>> token = str(qmsg['subject']).split()[1].strip() - >>> registrar.confirm(token) - True + >>> items = get_queue_messages('virgin') + >>> len(items) + 1 + >>> token = extract_token(items[0].msg) + >>> msg = message_from_string("""\ + ... To: baker-confirm+{token}@example.com + ... From: anne@example.com + ... Subject: Re: confirm {token} + ... + ... """.format(token=token)) + + >>> results = Results() + >>> print confirm.process(mlist_2, msg, {}, (token,), results) + ContinueProcessing.yes + >>> print unicode(results) + The results of your email command are provided below. + <BLANKLINE> + Confirmed + <BLANKLINE> >>> print mlist_2.members.get_member('anne@example.com') <Member: Anne Person <anne@example.com> @@ -180,10 +223,11 @@ Leaving a mailing list The mail command 'leave' unsubscribes an email address from the mailing list. 'unsubscribe' is an alias for 'leave'. - >>> command = config.commands['leave'] - >>> print command.name + >>> from mailman.commands.eml_membership import Leave + >>> leave = Leave() + >>> print leave.name leave - >>> print command.description + >>> print leave.description Leave this mailing list. You will be asked to confirm your request. Anne is a member of the baker@example.com mailing list, when she decides to @@ -191,7 +235,7 @@ leave it. She sends a message to the -leave address for the list and is sent a confirmation message for her request. >>> results = Results() - >>> print command.process(mlist_2, msg, {}, (), results) + >>> print leave.process(mlist_2, msg, {}, (), results) ContinueProcessing.yes >>> print unicode(results) The results of your email command are provided below. @@ -225,7 +269,7 @@ will do. Since Anne's alternative address has not yet been verified, it can't be used to unsubscribe Anne from the alpha mailing list. - >>> print command.process(mlist, msg, {}, (), results) + >>> print leave.process(mlist, msg, {}, (), results) ContinueProcessing.no >>> print unicode(results) @@ -245,7 +289,7 @@ unsubscribe her from the list. >>> address.verified_on = datetime.now() >>> results = Results() - >>> print command.process(mlist, msg, {}, (), results) + >>> print leave.process(mlist, msg, {}, (), results) ContinueProcessing.yes >>> print unicode(results) @@ -268,21 +312,18 @@ Bart wants to join the alpha list, so he sends his subscription request. ... ... """) - >>> command = config.commands['join'] - >>> print command.process(mlist, msg, {}, (), Results()) + >>> print join.process(mlist, msg, {}, (), Results()) ContinueProcessing.yes There are two messages in the virgin queue, one of which is the confirmation message. - >>> from mailman.testing.helpers import get_queue_messages >>> for item in get_queue_messages('virgin'): - ... subject = str(item.msg['subject']) - ... if subject.startswith('confirm'): + ... if str(item.msg['subject']).startswith('confirm'): ... break ... else: ... raise AssertionError('No confirmation message') - >>> token = subject.split()[1].strip() + >>> token = extract_token(item.msg) Bart is still not a user. @@ -295,14 +336,13 @@ a user of the system. >>> msg = message_from_string("""\ ... From: Bart Person <bart@example.com> - ... To: alpha-confirm@example.com + ... To: alpha-confirm+{token}@example.com ... Subject: Re: confirm {token} ... ... """.format(token=token)) - >>> command = config.commands['confirm'] >>> results = Results() - >>> print command.process(mlist, msg, {}, (token,), results) + >>> print confirm.process(mlist, msg, {}, (token,), results) ContinueProcessing.yes >>> print unicode(results) diff --git a/src/mailman/commands/eml_confirm.py b/src/mailman/commands/eml_confirm.py index 510033098..5232512b3 100644 --- a/src/mailman/commands/eml_confirm.py +++ b/src/mailman/commands/eml_confirm.py @@ -25,6 +25,7 @@ __all__ = [ ] +from zope.component import getUtility from zope.interface import implements from mailman.core.i18n import _ @@ -48,7 +49,7 @@ class Confirm: if len(arguments) == 0: print >> results, _('No confirmation token found') return ContinueProcessing.no - succeeded = IRegistrar(mlist.domain).confirm(arguments[0]) + succeeded = getUtility(IRegistrar).confirm(arguments[0]) if succeeded: print >> results, _('Confirmed') return ContinueProcessing.yes diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py index 2328e1a41..8b6c576f6 100644 --- a/src/mailman/commands/eml_membership.py +++ b/src/mailman/commands/eml_membership.py @@ -74,8 +74,7 @@ example: print >> results, _( '$self.name: No valid address found to subscribe') return ContinueProcessing.no - registrar = IRegistrar(mlist.domain) - registrar.register(mlist, address, real_name) + getUtility(IRegistrar).register(mlist, address, real_name) person = formataddr((real_name, address)) print >> results, _('Confirmation email sent to $person') return ContinueProcessing.yes |
