summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mailman/app/registrar.py4
-rw-r--r--mailman/bin/testall.py3
-rw-r--r--mailman/commands/docs/join.txt61
-rw-r--r--mailman/commands/join.py22
-rw-r--r--mailman/initialize.py34
5 files changed, 104 insertions, 20 deletions
diff --git a/mailman/app/registrar.py b/mailman/app/registrar.py
index 60fbd5f07..a0c3e56a7 100644
--- a/mailman/app/registrar.py
+++ b/mailman/app/registrar.py
@@ -20,6 +20,7 @@
__metaclass__ = type
__all__ = [
'Registrar',
+ 'adapt_domain_to_registrar',
]
@@ -27,7 +28,6 @@ import datetime
import pkg_resources
from zope.interface import implements
-from zope.interface.interface import adapter_hooks
from mailman.Message import UserNotification
from mailman.Utils import ValidateEmail
@@ -159,5 +159,3 @@ def adapt_domain_to_registrar(iface, obj):
return (Registrar(obj)
if IDomain.providedBy(obj) and iface is IRegistrar
else None)
-
-adapter_hooks.append(adapt_domain_to_registrar)
diff --git a/mailman/bin/testall.py b/mailman/bin/testall.py
index ed90980ae..8ecc6aedf 100644
--- a/mailman/bin/testall.py
+++ b/mailman/bin/testall.py
@@ -34,7 +34,7 @@ import pkg_resources
from mailman import Defaults
from mailman.configuration import config
from mailman.i18n import _
-from mailman.initialize import initialize_1, initialize_2
+from mailman.initialize import initialize_1, initialize_2, initialize_3
from mailman.testing.helpers import SMTPServer
from mailman.version import MAILMAN_VERSION
@@ -261,6 +261,7 @@ def main():
# With -vvv, turn on engine debugging.
initialize_2(parser.options.verbosity > 3)
+ initialize_3()
# Run the tests. XXX I'm not sure if basedir can be converted to
# pkg_resources.
diff --git a/mailman/commands/docs/join.txt b/mailman/commands/docs/join.txt
index d9163fbb6..4cc805e99 100644
--- a/mailman/commands/docs/join.txt
+++ b/mailman/commands/docs/join.txt
@@ -71,10 +71,63 @@ When the message has a From field, that address will be subscribed.
>>> print command.process(mlist, msg, {}, (), results)
ContinueProcessing.yes
>>> print unicode(results)
- XXX
+ The results of your email command are provided below.
+ <BLANKLINE>
+ Confirmation email sent to Anne Person <anne@example.com>
+ <BLANKLINE>
Anne is not yet a member because she must confirm her subscription request
-first. Mailman has sent her the confirmation message.
+first.
+
+ >>> print config.db.user_manager.get_user(u'anne@example.com')
+ None
+
+Mailman has sent her the confirmation message.
+
+ >>> from mailman.queue import Switchboard
+ >>> virginq = Switchboard(config.VIRGINQUEUE_DIR)
+ >>> qmsg, qdata = virginq.dequeue(virginq.files[0])
+ >>> print qmsg.as_string()
+ MIME-Version: 1.0
+ ...
+ Subject: confirm ...
+ From: confirm-...@example.com
+ To: anne@example.com
+ ...
+ <BLANKLINE>
+ Email Address Registration Confirmation
+ <BLANKLINE>
+ Hello, this is the GNU Mailman server at example.com.
+ <BLANKLINE>
+ We have received a registration request for the email address
+ <BLANKLINE>
+ anne@example.com
+ <BLANKLINE>
+ Before you can start using GNU Mailman at this site, you must first
+ confirm that this is your email address. You can do this by replying to
+ this message, keeping the Subject header intact. Or you can visit this
+ web page
+ <BLANKLINE>
+ http://www.example.com/confirm/...
+ <BLANKLINE>
+ If you do not wish to register this email address simply disregard this
+ message. If you think you are being maliciously subscribed to the list, or
+ have any other questions, you may contact
+ <BLANKLINE>
+ postmaster@example.com
+ <BLANKLINE>
+
+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.registrar import IRegistrar
+ >>> registrar = IRegistrar(config.domains['example.com'])
+ >>> registrar.confirm(token)
+ True
- >>> for message in smtpd.messages:
- ... print message.as_string()
+ >>> user = config.db.user_manager.get_user(u'anne@example.com')
+ >>> print user.real_name
+ Anne Person
+ >>> list(user.addresses)
+ [<Address: Anne Person <anne@example.com> [verified] at ...>]
diff --git a/mailman/commands/join.py b/mailman/commands/join.py
index bfc3435e7..45535470f 100644
--- a/mailman/commands/join.py
+++ b/mailman/commands/join.py
@@ -24,7 +24,7 @@ __all__ = [
from email.header import decode_header, make_header
-from email.utils import parseaddr
+from email.utils import formataddr, parseaddr
from zope.interface import implements
from mailman.Utils import MakeRandomPassword
@@ -32,6 +32,7 @@ from mailman.configuration import config
from mailman.i18n import _
from mailman.interfaces import (
ContinueProcessing, DeliveryMode, IEmailCommand)
+from mailman.interfaces.registrar import IRegistrar
@@ -56,9 +57,9 @@ example:
def process(self, mlist, msg, msgdata, arguments, results):
"""See `IEmailCommand`."""
# Parse the arguments.
- address, delivery_mmode = self._parse_arguments(arguments)
+ address, delivery_mode = self._parse_arguments(arguments)
if address is None:
- realname, address = parseaddr(msg['from'])
+ real_name, address = parseaddr(msg['from'])
# Address could be None or the empty string.
if not address:
address = msg.get_sender()
@@ -66,15 +67,11 @@ example:
print >> results, _(
'$self.name: No valid address found to subscribe')
return ContinueProcessing.no
- password = MakeRandomPassword()
- try:
- validate_subscription(mlist, address)
- confirm_subscription(mlist, address, realname, password,
- delivery_mode, mlist_preferred_language)
- except XXX:
- pass
- print >> results, self.name, address, \
- (_('digest delivery') if digest else _('regular delivery'))
+ domain = config.domains[mlist.host_name]
+ registrar = IRegistrar(domain)
+ registrar.register(address, real_name)
+ person = formataddr((real_name, address))
+ print >> results, _('Confirmation email sent to $person')
return ContinueProcessing.yes
def _parse_arguments(self, arguments):
@@ -122,6 +119,7 @@ example:
address = parts[1]
return address, delivery_mode
+
def ignore():
# Fill in empty defaults
if digest is None:
diff --git a/mailman/initialize.py b/mailman/initialize.py
index d8dc0d69d..3f098b67f 100644
--- a/mailman/initialize.py
+++ b/mailman/initialize.py
@@ -26,6 +26,7 @@ by the command line arguments.
import os
+from zope.interface.interface import adapter_hooks
from zope.interface.verify import verifyObject
import mailman.configuration
@@ -42,6 +43,17 @@ from mailman.interfaces import IDatabase
# code will just call initialize().
def initialize_1(config_path, propagate_logs):
+ """First initialization step.
+
+ * The configuration system
+ * Run-time directories
+ * The logging subsystem
+
+ :param config_path: The path to the configuration file.
+ :type config_path: string
+ :param propagate_logs: Should the log output propagate to stderr?
+ :type propagate_logs: boolean
+ """
# By default, set the umask so that only owner and group can read and
# write our files. Specifically we must have g+rw and we probably want
# o-rwx although I think in most cases it doesn't hurt if other can read
@@ -56,6 +68,17 @@ def initialize_1(config_path, propagate_logs):
def initialize_2(debug=False):
+ """Second initialization step.
+
+ * Archivers
+ * Rules
+ * Chains
+ * Pipelines
+ * Commands
+
+ :param debug: Should the database layer be put in debug mode?
+ :type debug: boolean
+ """
database_plugin = get_plugin('mailman.database')
# Instantiate the database plugin, ensure that it's of the right type, and
# initialize it. Then stash the object on our configuration object.
@@ -77,6 +100,17 @@ def initialize_2(debug=False):
initialize_commands()
+def initialize_3():
+ """Third initialization step.
+
+ * Adapters
+ """
+ from mailman.app.registrar import adapt_domain_to_registrar
+ adapter_hooks.append(adapt_domain_to_registrar)
+
+
+
def initialize(config_path=None, propagate_logs=False):
initialize_1(config_path, propagate_logs)
initialize_2()
+ initialize_3()