summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/docs/NEWS.rst2
-rw-r--r--src/mailman/interfaces/listmanager.py4
-rw-r--r--src/mailman/model/docs/listmanager.rst28
-rw-r--r--src/mailman/model/listmanager.py8
-rw-r--r--src/mailman/mta/postfix.py2
5 files changed, 38 insertions, 6 deletions
diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index 03aa586c2..79cc8d2b4 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -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
--------
diff --git a/src/mailman/interfaces/listmanager.py b/src/mailman/interfaces/listmanager.py
index 2f00b3e91..c4f21f809 100644
--- a/src/mailman/interfaces/listmanager.py
+++ b/src/mailman/interfaces/listmanager.py
@@ -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.
diff --git a/src/mailman/model/docs/listmanager.rst b/src/mailman/model/docs/listmanager.rst
index b571d9680..9c72b18e7 100644
--- a/src/mailman/model/docs/listmanager.rst
+++ b/src/mailman/model/docs/listmanager.rst
@@ -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('_xtest_3@example.com')
>>> mlist_4 = list_manager.create('_xtest_4@example.com')
- >>> sorted(list_manager.names)
- [u'_xtest@example.com', u'_xtest_3@example.com', u'_xtest_4@example.com']
- >>> sorted(m.fqdn_listname for m in list_manager.mailing_lists)
- [u'_xtest@example.com', u'_xtest_3@example.com', u'_xtest_4@example.com']
+
+ >>> for name in sorted(list_manager.names):
+ ... print name
+ _xtest@example.com
+ _xtest_3@example.com
+ _xtest_4@example.com
+
+ >>> for fqdn_listname in sorted(m.fqdn_listname
+ ... for m in list_manager.mailing_lists):
+ ... print fqdn_listname
+ _xtest@example.com
+ _xtest_3@example.com
+ _xtest_4@example.com
+
+ >>> 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
diff --git a/src/mailman/model/listmanager.py b/src/mailman/model/listmanager.py
index daf6b8425..db1f18ecb 100644
--- a/src/mailman/model/listmanager.py
+++ b/src/mailman/model/listmanager.py
@@ -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`."""
diff --git a/src/mailman/mta/postfix.py b/src/mailman/mta/postfix.py
index 2501dc0de..171e0737b 100644
--- a/src/mailman/mta/postfix.py
+++ b/src/mailman/mta/postfix.py
@@ -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: