------------------------------------------------------------
revno: 6640
committer: Barry Warsaw <[EMAIL PROTECTED]>
branch nick: domains
timestamp: Tue 2008-09-23 22:26:43 -0400
message:
Use adaptation to get from an IDomain to an IRegistrar.
modified:
TODO.txt
mailman/app/registrar.py
mailman/archiving/pipermail.py
mailman/docs/domains.txt
mailman/docs/registration.txt
=== modified file 'TODO.txt'
--- a/TODO.txt 2007-11-18 21:57:20 +0000
+++ b/TODO.txt 2008-09-24 02:26:43 +0000
@@ -8,7 +8,6 @@
Rework MTA plugins and add tests
Address XXX and FIXME
Fix the roster creation cruft for mailing lists
-Suss out the IDomain stuff
Remove Date: header from messagestore requirements (see list thread)
Handle moderation flag (see Mailman.app.membership)
Eradicate MailList.Lock() and friends.
=== modified file 'mailman/app/registrar.py'
--- a/mailman/app/registrar.py 2008-02-27 06:26:18 +0000
+++ b/mailman/app/registrar.py 2008-09-24 02:26:43 +0000
@@ -27,6 +27,7 @@
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
@@ -74,7 +75,7 @@
token = config.db.pendings.add(pendable)
# Set up some local variables for translation interpolation.
domain = IDomain(self._context)
- domain_name = _(domain.domain_name)
+ domain_name = _(domain.email_host)
contact_address = domain.contact_address
confirm_url = domain.confirm_url(token)
confirm_address = domain.confirm_address(token)
@@ -142,3 +143,21 @@
def discard(self, token):
# Throw the record away.
config.db.pendings.confirm(token)
+
+
+
+def adapt_domain_to_registrar(iface, obj):
+ """Adapt `IDomain` to `IRegistrar`.
+
+ :param iface: The interface to adapt to.
+ :type iface: `zope.interface.Interface`
+ :param obj: The object being adapted.
+ :type obj: `IDomain`
+ :return: An `IRegistrar` instance if adaptation succeeded or None if it
+ didn't.
+ """
+ return (Registrar(obj)
+ if IDomain.providedBy(obj) and iface is IRegistrar
+ else None)
+
+adapter_hooks.append(adapt_domain_to_registrar)
=== modified file 'mailman/archiving/pipermail.py'
--- a/mailman/archiving/pipermail.py 2008-09-20 04:33:07 +0000
+++ b/mailman/archiving/pipermail.py 2008-09-24 02:26:43 +0000
@@ -68,9 +68,9 @@
:return: An `IPipermailMailingList` instance if adaptation succeeded or
None if it didn't.
"""
- if IMailingList.providedBy(obj) and iface is IPipermailMailingList:
- return PipermailMailingListAdapter(obj)
- return None
+ return (PipermailMailingListAdapter(obj)
+ if IMailingList.providedBy(obj) and iface is IPipermailMailingList
+ else None)
adapter_hooks.append(adapt_mailing_list_for_pipermail)
=== modified file 'mailman/docs/domains.txt'
--- a/mailman/docs/domains.txt 2008-09-20 04:33:07 +0000
+++ b/mailman/docs/domains.txt 2008-09-24 02:26:43 +0000
@@ -12,7 +12,12 @@
The domain object can be looked up by email host name.
+ >>> from zope.interface.verify import verifyObject
+ >>> from mailman.interfaces.domain import IDomain
>>> domain = config.domains['example.net']
+ >>> verifyObject(IDomain, domain)
+ True
+
>>> print domain.email_host
example.net
=== modified file 'mailman/docs/registration.txt'
--- a/mailman/docs/registration.txt 2008-02-27 06:26:18 +0000
+++ b/mailman/docs/registration.txt 2008-09-24 02:26:43 +0000
@@ -16,27 +16,11 @@
checks, etc. The IRegistrar is the interface to the object handling all this
stuff.
-Create a dummy domain, which will provide the context for the verification
-email message.
+Add a domain, which will provide the context for the verification email
+message.
- >>> from zope.interface import implements
- >>> from mailman.interfaces import IDomain
- >>> class TestDomain(object):
- ... implements(IDomain)
- ... def __init__(self):
- ... self.domain_name = 'example.com'
- ... self.description = 'mail.example.com'
- ... self.contact_address = '[EMAIL PROTECTED]'
- ... self.base_url = 'http://mail.example.com'
- ... def confirm_address(self, token=''):
- ... return '[EMAIL PROTECTED]' % token
- ... def confirm_url(self, token=''):
- ... return self.base_url + '/confirm/' + token
- ... def __conform__(self, protocol):
- ... if protocol is IRegistrar:
- ... return Registrar(self)
- ... return None
- >>> domain = TestDomain()
+ >>> config.add_domain('mail.example.com', 'http://mail.example.com')
+ >>> domain = config.domains['mail.example.com']
Get a registrar by adapting a context to the interface.
@@ -143,7 +127,7 @@
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Subject: confirm ...
- From: [EMAIL PROTECTED]
+ From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Message-ID: <...>
Date: ...
@@ -151,7 +135,7 @@
<BLANKLINE>
Email Address Registration Confirmation
<BLANKLINE>
- Hello, this is the GNU Mailman server at example.com.
+ Hello, this is the GNU Mailman server at mail.example.com.
<BLANKLINE>
We have received a registration request for the email address
<BLANKLINE>
@@ -165,8 +149,8 @@
http://mail.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
+ message. If you think you are being maliciously subscribed to the list,
+ or have any other questions, you may contact
<BLANKLINE>
[EMAIL PROTECTED]
<BLANKLINE>
@@ -188,7 +172,7 @@
The same token will appear in the From header.
- >>> qmsg['from'] == 'confirm+' + token + '@example.com'
+ >>> qmsg['from'] == 'confirm-' + token + '@mail.example.com'
True
It will also appear in the Subject header.
@@ -344,6 +328,8 @@
pending even matched with that token will still be removed.
>>> from mailman.interfaces import IPendable
+ >>> from zope.interface import implements
+
>>> class SimplePendable(dict):
... implements(IPendable)
>>> pendable = SimplePendable(type='foo', bar='baz')
--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0
You are receiving this branch notification because you are subscribed to it.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org