summaryrefslogtreecommitdiff
path: root/src/mailman/commands/docs
diff options
context:
space:
mode:
authorBarry Warsaw2009-12-08 22:39:10 -0500
committerBarry Warsaw2009-12-08 22:39:10 -0500
commit3d65590999f5288307ecb0df6ae1b77241869f61 (patch)
tree7047453b1ddfbc6d5715834553f46e3362d3e1da /src/mailman/commands/docs
parent24f92b6c842bfa3701cb708e4aee3c991f206c9d (diff)
downloadmailman-3d65590999f5288307ecb0df6ae1b77241869f61.tar.gz
mailman-3d65590999f5288307ecb0df6ae1b77241869f61.tar.zst
mailman-3d65590999f5288307ecb0df6ae1b77241869f61.zip
* Make IDomainManager a utility, since the config object is global.
* Give IMailingList a .domain attribute which looks up the IDomain for its .host_name. This cleans up a lot of code. * Add a test for the 'confirm' email command. * Suppress blank lines in email command responses. * Make the IDomainCollection a utility.
Diffstat (limited to 'src/mailman/commands/docs')
-rw-r--r--src/mailman/commands/docs/create.txt2
-rw-r--r--src/mailman/commands/docs/lists.txt5
-rw-r--r--src/mailman/commands/docs/membership.txt71
3 files changed, 69 insertions, 9 deletions
diff --git a/src/mailman/commands/docs/create.txt b/src/mailman/commands/docs/create.txt
index eec8b6941..9c2331418 100644
--- a/src/mailman/commands/docs/create.txt
+++ b/src/mailman/commands/docs/create.txt
@@ -43,7 +43,7 @@ Now both the domain and the mailing list exist in the database.
<mailing list "test@example.xx" at ...>
>>> from mailman.interfaces.domain import IDomainManager
- >>> IDomainManager(config).get('example.xx')
+ >>> getUtility(IDomainManager).get('example.xx')
<Domain example.xx, base_url: http://example.xx,
contact_address: postmaster@example.xx>
diff --git a/src/mailman/commands/docs/lists.txt b/src/mailman/commands/docs/lists.txt
index ee4ec35e2..887e69bd4 100644
--- a/src/mailman/commands/docs/lists.txt
+++ b/src/mailman/commands/docs/lists.txt
@@ -20,10 +20,9 @@ line. When there are no mailing lists, a helpful message is displayed.
When there are a few mailing lists, they are shown in alphabetical order by
their fully qualified list names, with a description.
- >>> from mailman.config import config
>>> from mailman.interfaces.domain import IDomainManager
- >>> domain_mgr = IDomainManager(config)
- >>> domain_mgr.add('example.net')
+ >>> from zope.component import getUtility
+ >>> getUtility(IDomainManager).add('example.net')
<Domain example.net...>
>>> mlist_1 = create_list('list-one@example.com')
diff --git a/src/mailman/commands/docs/membership.txt b/src/mailman/commands/docs/membership.txt
index f3d9ae1df..b91dd17f1 100644
--- a/src/mailman/commands/docs/membership.txt
+++ b/src/mailman/commands/docs/membership.txt
@@ -80,7 +80,8 @@ first.
>>> from mailman.interfaces.usermanager import IUserManager
>>> from zope.component import getUtility
- >>> print getUtility(IUserManager).get_user('anne@example.com')
+ >>> user_manager = getUtility(IUserManager)
+ >>> print user_manager.get_user('anne@example.com')
None
Mailman has sent her the confirmation message.
@@ -123,11 +124,11 @@ list.
>>> token = str(qmsg['subject']).split()[1].strip()
>>> from mailman.interfaces.domain import IDomainManager
>>> from mailman.interfaces.registrar import IRegistrar
- >>> registrar = IRegistrar(IDomainManager(config)['example.com'])
+ >>> registrar = IRegistrar(getUtility(IDomainManager)['example.com'])
>>> registrar.confirm(token)
True
- >>> user = getUtility(IUserManager).get_user('anne@example.com')
+ >>> user = user_manager.get_user('anne@example.com')
>>> print user.real_name
Anne Person
>>> list(user.addresses)
@@ -153,7 +154,7 @@ Joining a second list
Anne of course, is still registered.
- >>> print getUtility(IUserManager).get_user('anne@example.com')
+ >>> print user_manager.get_user('anne@example.com')
<User "Anne Person" at ...>
But she is not a member of the mailing list.
@@ -207,7 +208,7 @@ Anne does not need to leave a mailing list with the same email address she's
subscribe with. Any of her registered, linked, and validated email addresses
will do.
- >>> anne = getUtility(IUserManager).get_user('anne@example.com')
+ >>> anne = user_manager.get_user('anne@example.com')
>>> address = anne.register('anne.person@example.org')
>>> results = Results()
@@ -260,3 +261,63 @@ unsubscribe her from the list.
Confirmations
=============
+Bart wants to join the alpha list, so he sends his subscription request.
+
+ >>> msg = message_from_string("""\
+ ... From: Bart Person <bart@example.com>
+ ...
+ ... """)
+
+ >>> command = config.commands['join']
+ >>> print command.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'):
+ ... break
+ ... else:
+ ... raise AssertionError('No confirmation message')
+ >>> token = subject.split()[1].strip()
+
+Bart is still not a user.
+
+ >>> print user_manager.get_user('bart@example.com')
+ None
+
+Bart replies to the original message, specifically keeping the Subject header
+intact except for any prefix. Mailman matches the token and confirms Bart as
+a user of the system.
+
+ >>> msg = message_from_string("""\
+ ... From: Bart Person <bart@example.com>
+ ... To: alpha-confirm@example.com
+ ... Subject: Re: confirm {token}
+ ...
+ ... """.format(token=token))
+
+ >>> command = config.commands['confirm']
+ >>> results = Results()
+ >>> print command.process(mlist, msg, {}, (token,), results)
+ ContinueProcessing.yes
+
+ >>> print unicode(results)
+ The results of your email command are provided below.
+ <BLANKLINE>
+ Confirmed
+ <BLANKLINE>
+
+Now Bart is a user...
+
+ >>> print user_manager.get_user('bart@example.com')
+ <User "Bart Person" at ...>
+
+...and a member of the mailing list.
+
+ >>> print mlist.members.get_member('bart@example.com')
+ <Member: Bart Person <bart@example.com>
+ on alpha@example.com as MemberRole.member>