Commit 1159b786 authored by Barry Warsaw's avatar Barry Warsaw

* Add property `IListmanager.name_compoments` which returns 2-tuples for

   every mailing list as (list_name, mail_host).
parent cdfc752b
......@@ -24,6 +24,8 @@ Architecture
Interfaces
----------
* Add property `IUserManager.members` to return all `IMembers` in the system.
* Add property `IListmanager.name_compoments` which returns 2-tuples for
every mailing list as (list_name, mail_host).
Commands
--------
......
......@@ -134,6 +134,10 @@ class IListManager(Interface):
"""An iterator over the fully qualified list names of all mailing
lists managed by this list manager.""")
name_components = Attribute(
"""An iterator over the 2-tuple of (list_name, mail_host) for all
mailing lists managed by this list manager.""")
def get_mailing_lists():
"""The list of all mailing lists.
......
......@@ -89,11 +89,29 @@ Iterating over all mailing lists
================================
Once you've created a bunch of mailing lists, you can use the list manager to
iterate over either the list objects, or the list names.
iterate over the mailing list objects, the list posting addresses, or the list
address components.
::
>>> mlist_3 = list_manager.create('[email protected]')
>>> mlist_4 = list_manager.create('[email protected]')
>>> sorted(list_manager.names)
[u'[email protected]', u'[email protected]', u'[email protected]']
>>> sorted(m.fqdn_listname for m in list_manager.mailing_lists)
[u'[email protected]', u'[email protected]', u'[email protected]']
>>> for name in sorted(list_manager.names):
... print name
[email protected]
[email protected]
[email protected]
>>> for fqdn_listname in sorted(m.fqdn_listname
... for m in list_manager.mailing_lists):
... print fqdn_listname
[email protected]
[email protected]
[email protected]
>>> for list_name, mail_host in sorted(list_manager.name_components,
... key=lambda (name, host): name):
... print list_name, '@', mail_host
_xtest @ example.com
_xtest_3 @ example.com
_xtest_4 @ example.com
......@@ -95,6 +95,14 @@ class ListManager:
MailingList.list_name):
yield '{0}@{1}'.format(list_name, mail_host)
@property
def name_components(self):
"""See `IListManager`."""
result_set = config.db.store.find(MailingList)
for mail_host, list_name in result_set.values(MailingList.mail_host,
MailingList.list_name):
yield list_name, mail_host
# XXX 2010-02-24 barry Get rid of this.
def get_mailing_lists(self):
"""See `IListManager`."""
......
......@@ -100,7 +100,7 @@ class LMTP:
def _do_write_file(self, fp):
"""Do the actual file writes for list creation."""
# Sort all existing mailing list names first by domain, then my local
# Sort all existing mailing list names first by domain, then by local
# part. For postfix we need a dummy entry for the domain.
by_domain = {}
for mlist in getUtility(IListManager).mailing_lists:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment