summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2009-08-21 18:07:35 -0400
committerBarry Warsaw2009-08-21 18:07:35 -0400
commitd1718e1a1cc289344d2a68c7430c492a4a7966b6 (patch)
treed6b404e8544c83de5a3516a8206c7da92d9d088f /src
parentda566eb047608ed2e65c71dd25979f01c825c843 (diff)
downloadmailman-d1718e1a1cc289344d2a68c7430c492a4a7966b6.tar.gz
mailman-d1718e1a1cc289344d2a68c7430c492a4a7966b6.tar.zst
mailman-d1718e1a1cc289344d2a68c7430c492a4a7966b6.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/bin/list_members.py5
-rw-r--r--src/mailman/bin/list_owners.py3
-rw-r--r--src/mailman/bin/withlist.py3
-rw-r--r--src/mailman/commands/docs/create.txt14
-rw-r--r--src/mailman/commands/docs/remove.txt8
-rw-r--r--src/mailman/docs/bounces.txt3
-rw-r--r--src/mailman/docs/lifecycle.txt4
-rw-r--r--src/mailman/docs/listmanager.txt26
-rw-r--r--src/mailman/docs/mlist-addresses.txt3
-rw-r--r--src/mailman/docs/styles.txt3
-rw-r--r--src/mailman/mta/postfix.py3
-rw-r--r--src/mailman/pipeline/docs/ack-headers.txt6
-rw-r--r--src/mailman/pipeline/docs/acknowledge.txt6
-rw-r--r--src/mailman/pipeline/docs/after-delivery.txt6
-rw-r--r--src/mailman/pipeline/docs/avoid-duplicates.txt6
-rw-r--r--src/mailman/pipeline/docs/calc-recips.txt6
-rw-r--r--src/mailman/pipeline/docs/cleanse.txt6
-rw-r--r--src/mailman/pipeline/docs/decorate.txt5
-rw-r--r--src/mailman/pipeline/docs/file-recips.txt6
-rw-r--r--src/mailman/pipeline/docs/nntp.txt10
-rw-r--r--src/mailman/pipeline/docs/reply-to.txt7
-rw-r--r--src/mailman/pipeline/docs/scrubber.txt9
-rw-r--r--src/mailman/pipeline/docs/subject-munging.txt7
-rw-r--r--src/mailman/pipeline/docs/tagger.txt6
-rw-r--r--src/mailman/pipeline/docs/to-outgoing.txt8
-rw-r--r--src/mailman/queue/__init__.py3
-rw-r--r--src/mailman/queue/docs/news.txt6
-rw-r--r--src/mailman/queue/docs/runner.txt4
-rw-r--r--src/mailman/queue/lmtp.py3
-rw-r--r--src/mailman/rest/docs/lists.txt3
-rw-r--r--src/mailman/rest/urls.py3
-rw-r--r--src/mailman/rest/webservice.py3
-rw-r--r--src/mailman/rules/docs/administrivia.txt3
-rw-r--r--src/mailman/rules/docs/approve.txt3
-rw-r--r--src/mailman/rules/docs/loop.txt3
-rw-r--r--src/mailman/rules/docs/max-size.txt3
-rw-r--r--src/mailman/rules/docs/moderation.txt3
-rw-r--r--src/mailman/rules/docs/news-moderation.txt3
-rw-r--r--src/mailman/rules/docs/no-subject.txt3
-rw-r--r--src/mailman/rules/docs/recipients.txt3
-rw-r--r--src/mailman/rules/docs/rules.txt3
-rw-r--r--src/mailman/rules/docs/suspicious.txt3
42 files changed, 139 insertions, 85 deletions
diff --git a/src/mailman/bin/list_members.py b/src/mailman/bin/list_members.py
index 4ba0a95db..d876fe729 100644
--- a/src/mailman/bin/list_members.py
+++ b/src/mailman/bin/list_members.py
@@ -23,7 +23,8 @@ from mailman.config import config
from mailman.core import errors
from mailman.email.validate import is_valid
from mailman.i18n import _
-from mailman.interfaces import DeliveryStatus
+from mailman.interfaces.listmanager import IListManager
+from mailman.interfaces.members import DeliveryStatus
from mailman.options import SingleMailingListOptions
@@ -142,7 +143,7 @@ def main():
else:
fp = sys.stdout
- mlist = config.db.list_manager.get(fqdn_listname)
+ mlist = IListManager(config).get(fqdn_listname)
if mlist is None:
options.parser.error(_('No such list: $fqdn_listname'))
diff --git a/src/mailman/bin/list_owners.py b/src/mailman/bin/list_owners.py
index 953fb8941..515148d57 100644
--- a/src/mailman/bin/list_owners.py
+++ b/src/mailman/bin/list_owners.py
@@ -22,6 +22,7 @@ from mailman.MailList import MailList
from mailman.configuration import config
from mailman.i18n import _
from mailman.initialize import initialize
+from mailman.interfaces.listmanager import IListManager
from mailman.version import MAILMAN_VERSION
@@ -53,7 +54,7 @@ def main():
parser, opts, args = parseargs()
initialize(opts.config)
- listmgr = config.db.list_manager
+ listmgr = IListManager(config)
listnames = set(args or listmgr.names)
bylist = {}
diff --git a/src/mailman/bin/withlist.py b/src/mailman/bin/withlist.py
index 8f2d8a2b5..0fa704209 100644
--- a/src/mailman/bin/withlist.py
+++ b/src/mailman/bin/withlist.py
@@ -23,6 +23,7 @@ from mailman import interact
from mailman.config import config
from mailman.core.initialize import initialize
from mailman.i18n import _
+from mailman.interfaces.listmanager import IListManager
from mailman.version import MAILMAN_VERSION
@@ -40,7 +41,7 @@ def do_list(listname, args, func):
# XXX FIXME Remove this when this script is converted to
# MultipleMailingListOptions.
listname = listname.decode(sys.getdefaultencoding())
- mlist = config.db.list_manager.get(listname)
+ mlist = IListManager(config).get(listname)
if mlist is None:
print >> sys.stderr, _('Unknown list: $listname')
else:
diff --git a/src/mailman/commands/docs/create.txt b/src/mailman/commands/docs/create.txt
index e882b7a77..349714a67 100644
--- a/src/mailman/commands/docs/create.txt
+++ b/src/mailman/commands/docs/create.txt
@@ -36,7 +36,9 @@ the mailing list and domain will be created.
Now both the domain and the mailing list exist in the database.
- >>> config.db.list_manager.get('test@example.xx')
+ >>> from mailman.interfaces.listmanager import IListManager
+ >>> list_manager = IListManager(config)
+ >>> list_manager.get('test@example.xx')
<mailing list "test@example.xx" at ...>
>>> from mailman.interfaces.domain import IDomainManager
@@ -52,7 +54,7 @@ auto-creation flag.
>>> command.process(args)
Created mailing list: test1@example.com
- >>> config.db.list_manager.get('test1@example.com')
+ >>> list_manager.get('test1@example.com')
<mailing list "test1@example.com" at ...>
The command can also operate quietly.
@@ -61,7 +63,7 @@ The command can also operate quietly.
>>> args.listname = ['test2@example.com']
>>> command.process(args)
- >>> mlist = config.db.list_manager.get('test2@example.com')
+ >>> mlist = list_manager.get('test2@example.com')
>>> mlist
<mailing list "test2@example.com" at ...>
@@ -83,7 +85,7 @@ mailing list.
>>> command.process(args)
Created mailing list: test4@example.com
- >>> mlist = config.db.list_manager.get('test4@example.com')
+ >>> mlist = list_manager.get('test4@example.com')
>>> print list(mlist.owners.addresses)
[<Address: foo@example.org [not verified] at ...>]
@@ -94,7 +96,7 @@ You can even specify more than one address for the owners.
>>> command.process(args)
Created mailing list: test5@example.com
- >>> mlist = config.db.list_manager.get('test5@example.com')
+ >>> mlist = list_manager.get('test5@example.com')
>>> from operator import attrgetter
>>> print sorted(mlist.owners.addresses, key=attrgetter('address'))
[<Address: bar@example.net [not verified] at ...>,
@@ -121,7 +123,7 @@ The language must be known to Mailman.
>>> command.process(args)
Created mailing list: test3@example.com
- >>> mlist = config.db.list_manager.get('test3@example.com')
+ >>> mlist = list_manager.get('test3@example.com')
>>> print mlist.preferred_language
<Language [it] Italian>
>>> args.language = None
diff --git a/src/mailman/commands/docs/remove.txt b/src/mailman/commands/docs/remove.txt
index be623ccf4..667b5d8c1 100644
--- a/src/mailman/commands/docs/remove.txt
+++ b/src/mailman/commands/docs/remove.txt
@@ -8,7 +8,9 @@ A system administrator can remove mailing lists by the command line.
>>> create_list('test@example.com')
<mailing list "test@example.com" at ...>
- >>> config.db.list_manager.get('test@example.com')
+ >>> from mailman.interfaces.listmanager import IListManager
+ >>> list_manager = IListManager(config)
+ >>> list_manager.get('test@example.com')
<mailing list "test@example.com" at ...>
>>> class FakeArgs:
@@ -23,7 +25,7 @@ A system administrator can remove mailing lists by the command line.
Removed list: test@example.com
Not removing archives. Reinvoke with -a to remove them.
- >>> print config.db.list_manager.get('test@example.com')
+ >>> print list_manager.get('test@example.com')
None
You can also remove lists quietly.
@@ -35,7 +37,7 @@ You can also remove lists quietly.
>>> args.quiet = True
>>> command.process(args)
- >>> print config.db.list_manager.get('test@example.com')
+ >>> print list_manager.get('test@example.com')
None
diff --git a/src/mailman/docs/bounces.txt b/src/mailman/docs/bounces.txt
index 5408af2cc..c5ffb3e11 100644
--- a/src/mailman/docs/bounces.txt
+++ b/src/mailman/docs/bounces.txt
@@ -13,7 +13,8 @@ Mailman can also bounce messages back to the original sender. This is
essentially equivalent to rejecting the message with notification. Mailing
lists can bounce a message with an optional error message.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.interfaces.listmanager import IListManager
+ >>> mlist = IListManager(config).create('_xtest@example.com')
>>> mlist.preferred_language = 'en'
Any message can be bounced.
diff --git a/src/mailman/docs/lifecycle.txt b/src/mailman/docs/lifecycle.txt
index e6dcc7c33..8dbb34abd 100644
--- a/src/mailman/docs/lifecycle.txt
+++ b/src/mailman/docs/lifecycle.txt
@@ -125,7 +125,9 @@ artifacts.
>>> from mailman.app.lifecycle import remove_list
>>> remove_list(mlist_2.fqdn_listname, mlist_2, True)
- >>> print config.db.list_manager.get('test_2@example.com')
+
+ >>> from mailman.interfaces.listmanager import IListManager
+ >>> print IListManager(config).get('test_2@example.com')
None
We should now be able to completely recreate the mailing list.
diff --git a/src/mailman/docs/listmanager.txt b/src/mailman/docs/listmanager.txt
index c432a8613..b366817c7 100644
--- a/src/mailman/docs/listmanager.txt
+++ b/src/mailman/docs/listmanager.txt
@@ -8,9 +8,7 @@ configuration variable MANAGERS_INIT_FUNCTION. The instance is accessible
on the global config object.
>>> from mailman.interfaces.listmanager import IListManager
- >>> listmgr = config.db.list_manager
- >>> IListManager.providedBy(listmgr)
- True
+ >>> list_manager = IListManager(config)
Creating a mailing list
@@ -19,7 +17,7 @@ Creating a mailing list
Creating the list returns the newly created IMailList object.
>>> from mailman.interfaces.mailinglist import IMailingList
- >>> mlist = listmgr.create('_xtest@example.com')
+ >>> mlist = list_manager.create('_xtest@example.com')
>>> IMailingList.providedBy(mlist)
True
@@ -37,7 +35,7 @@ list to the system.
If you try to create a mailing list with the same name as an existing list,
you will get an exception.
- >>> mlist_dup = listmgr.create('_xtest@example.com')
+ >>> mlist_dup = list_manager.create('_xtest@example.com')
Traceback (most recent call last):
...
ListAlreadyExistsError: _xtest@example.com
@@ -48,13 +46,13 @@ Deleting a mailing list
Use the list manager to delete a mailing list.
- >>> listmgr.delete(mlist)
- >>> sorted(listmgr.names)
+ >>> list_manager.delete(mlist)
+ >>> sorted(list_manager.names)
[]
After deleting the list, you can create it again.
- >>> mlist = listmgr.create('_xtest@example.com')
+ >>> mlist = list_manager.create('_xtest@example.com')
>>> print mlist.fqdn_listname
_xtest@example.com
@@ -65,13 +63,13 @@ Retrieving a mailing list
When a mailing list exists, you can ask the list manager for it and you will
always get the same object back.
- >>> mlist_2 = listmgr.get('_xtest@example.com')
+ >>> mlist_2 = list_manager.get('_xtest@example.com')
>>> mlist_2 is mlist
True
If you try to get a list that doesn't existing yet, you get None.
- >>> print listmgr.get('_xtest_2@example.com')
+ >>> print list_manager.get('_xtest_2@example.com')
None
@@ -81,9 +79,9 @@ 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.
- >>> mlist_3 = listmgr.create('_xtest_3@example.com')
- >>> mlist_4 = listmgr.create('_xtest_4@example.com')
- >>> sorted(listmgr.names)
+ >>> 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 listmgr.mailing_lists)
+ >>> 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']
diff --git a/src/mailman/docs/mlist-addresses.txt b/src/mailman/docs/mlist-addresses.txt
index 48d25a8f3..6aa9c7213 100644
--- a/src/mailman/docs/mlist-addresses.txt
+++ b/src/mailman/docs/mlist-addresses.txt
@@ -4,7 +4,8 @@ Mailing list addresses
Every mailing list has a number of addresses which are publicly available.
These are defined in the IMailingListAddresses interface.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.interfaces.listmanager import IListManager
+ >>> mlist = IListManager(config).create('_xtest@example.com')
The posting address is where people send messages to be posted to the mailing
list. This is exactly the same as the fully qualified list name.
diff --git a/src/mailman/docs/styles.txt b/src/mailman/docs/styles.txt
index 7524ecf64..3994e750f 100644
--- a/src/mailman/docs/styles.txt
+++ b/src/mailman/docs/styles.txt
@@ -14,7 +14,8 @@ modify the mailing list any way it wants.
Let's start with a vanilla mailing list and a default style manager.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.interfaces.listmanager import IListManager
+ >>> mlist = IListManager(config).create('_xtest@example.com')
>>> from mailman.styles.manager import StyleManager
>>> style_manager = StyleManager()
>>> style_manager.populate()
diff --git a/src/mailman/mta/postfix.py b/src/mailman/mta/postfix.py
index 4cb172d99..e9398f11d 100644
--- a/src/mailman/mta/postfix.py
+++ b/src/mailman/mta/postfix.py
@@ -38,6 +38,7 @@ from zope.interface import implements
from mailman import Utils
from mailman.config import config
+from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.mta import IMailTransportAgent
from mailman.i18n import _
@@ -79,7 +80,7 @@ class LMTP:
# Sort all existing mailing list names first by domain, then my local
# part. For postfix we need a dummy entry for the domain.
by_domain = {}
- for mailing_list in config.db.list_manager.mailing_lists:
+ for mailing_list in IListManager(config).mailing_lists:
by_domain.setdefault(mailing_list.host_name, []).append(
mailing_list.list_name)
with open(path + '.new', 'w') as fp:
diff --git a/src/mailman/pipeline/docs/ack-headers.txt b/src/mailman/pipeline/docs/ack-headers.txt
index 49b203cad..ddaa313dc 100644
--- a/src/mailman/pipeline/docs/ack-headers.txt
+++ b/src/mailman/pipeline/docs/ack-headers.txt
@@ -8,8 +8,8 @@ transformations. Some headers get added, others get changed. Some of these
changes depend on mailing list settings and others depend on how the message
is getting sent through the system. We'll take things one-by-one.
- >>> from mailman.pipeline.cook_headers import process
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> mlist.subject_prefix = ''
When the message's metadata has a 'noack' key set, an 'X-Ack: no' header is
@@ -20,6 +20,8 @@ added.
...
... A message of great import.
... """)
+
+ >>> from mailman.pipeline.cook_headers import process
>>> process(mlist, msg, dict(noack=True))
>>> print msg.as_string()
From: aperson@example.com
diff --git a/src/mailman/pipeline/docs/acknowledge.txt b/src/mailman/pipeline/docs/acknowledge.txt
index 72292cd80..bde84349f 100644
--- a/src/mailman/pipeline/docs/acknowledge.txt
+++ b/src/mailman/pipeline/docs/acknowledge.txt
@@ -6,8 +6,8 @@ When a user posts a message to a mailing list, and that user has chosen to
receive acknowledgments of their postings, Mailman will sent them such an
acknowledgment.
- >>> handler = config.handlers['acknowledge']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> mlist.real_name = 'XTest'
>>> mlist.preferred_language = 'en'
>>> # XXX This will almost certainly change once we've worked out the web
@@ -38,6 +38,8 @@ Non-members can't get acknowledgments of their posts to the mailing list.
... From: bperson@example.com
...
... """)
+
+ >>> handler = config.handlers['acknowledge']
>>> handler.process(mlist, msg, {})
>>> virginq.files
[]
diff --git a/src/mailman/pipeline/docs/after-delivery.txt b/src/mailman/pipeline/docs/after-delivery.txt
index da1a3af08..19673d91c 100644
--- a/src/mailman/pipeline/docs/after-delivery.txt
+++ b/src/mailman/pipeline/docs/after-delivery.txt
@@ -7,8 +7,8 @@ by the rest of the handlers in the incoming queue pipeline, a couple of
bookkeeping pieces of information are updated.
>>> import datetime
- >>> handler = config.handlers['after-delivery']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> post_time = datetime.datetime.now() - datetime.timedelta(minutes=10)
>>> mlist.last_post_time = post_time
>>> mlist.post_id = 10
@@ -21,6 +21,8 @@ attributes.
...
... Something interesting.
... """)
+
+ >>> handler = config.handlers['after-delivery']
>>> handler.process(mlist, msg, {})
>>> mlist.last_post_time > post_time
True
diff --git a/src/mailman/pipeline/docs/avoid-duplicates.txt b/src/mailman/pipeline/docs/avoid-duplicates.txt
index adca9cbe5..aef50aa6e 100644
--- a/src/mailman/pipeline/docs/avoid-duplicates.txt
+++ b/src/mailman/pipeline/docs/avoid-duplicates.txt
@@ -7,8 +7,8 @@ reduce the reception of duplicate messages. It does this by removing certain
recipients from the list of recipients that earlier handler modules
(e.g. CalcRecips) calculates.
- >>> handler = config.handlers['avoid-duplicates']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Create some members we're going to use.
@@ -36,6 +36,8 @@ The module short-circuits if there are no recipients.
... Something
... """)
>>> msgdata = {}
+
+ >>> handler = config.handlers['avoid-duplicates']
>>> handler.process(mlist, msg, msgdata)
>>> msgdata
{}
diff --git a/src/mailman/pipeline/docs/calc-recips.txt b/src/mailman/pipeline/docs/calc-recips.txt
index 03a22e5dc..e787e650d 100644
--- a/src/mailman/pipeline/docs/calc-recips.txt
+++ b/src/mailman/pipeline/docs/calc-recips.txt
@@ -6,8 +6,8 @@ Every message that makes it through to the list membership gets sent to a set
of recipient addresses. These addresses are calculated by one of the handler
modules and depends on a host of factors.
- >>> handler = config.handlers['calculate-recipients']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Recipients are calculate from the list members, so add a bunch of members to
start out with. First, create a bunch of addresses...
@@ -52,6 +52,8 @@ but not all of the recipients.
... """)
>>> recips = set(('qperson@example.com', 'zperson@example.com'))
>>> msgdata = dict(recips=recips)
+
+ >>> handler = config.handlers['calculate-recipients']
>>> handler.process(mlist, msg, msgdata)
>>> sorted(msgdata['recips'])
[u'qperson@example.com', u'zperson@example.com']
diff --git a/src/mailman/pipeline/docs/cleanse.txt b/src/mailman/pipeline/docs/cleanse.txt
index 778ecb19d..a1838d36e 100644
--- a/src/mailman/pipeline/docs/cleanse.txt
+++ b/src/mailman/pipeline/docs/cleanse.txt
@@ -6,8 +6,8 @@ All messages posted to a list get their headers cleansed. Some headers are
related to additional permissions that can be granted to the message and other
headers can be used to fish for membership.
- >>> handler = config.handlers['cleanse']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Headers such as Approved, Approve, and Urgent are used to grant special
pemissions to individual messages. All may contain a password; the first two
@@ -25,6 +25,8 @@ headers contain passwords, they must be removed from any posted message.
...
... Blah blah blah
... """)
+
+ >>> handler = config.handlers['cleanse']
>>> handler.process(mlist, msg, {})
>>> print msg.as_string()
From: aperson@example.com
diff --git a/src/mailman/pipeline/docs/decorate.txt b/src/mailman/pipeline/docs/decorate.txt
index ee2f4d10e..42afe9a80 100644
--- a/src/mailman/pipeline/docs/decorate.txt
+++ b/src/mailman/pipeline/docs/decorate.txt
@@ -6,8 +6,8 @@ Message decoration is the process of adding headers and footers to the
original message. A handler module takes care of this based on the settings
of the mailing list and the type of message being processed.
- >>> from mailman.pipeline.decorate import process
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> msg_text = """\
... From: aperson@example.org
...
@@ -22,6 +22,7 @@ Short circuiting
Digest messages get decorated during the digest creation phase so no extra
decorations are added for digest messages.
+ >>> from mailman.pipeline.decorate import process
>>> process(mlist, msg, dict(isdigest=True))
>>> print msg.as_string()
From: aperson@example.org
diff --git a/src/mailman/pipeline/docs/file-recips.txt b/src/mailman/pipeline/docs/file-recips.txt
index 479ae9975..2c9d7724f 100644
--- a/src/mailman/pipeline/docs/file-recips.txt
+++ b/src/mailman/pipeline/docs/file-recips.txt
@@ -6,8 +6,8 @@ Mailman can calculate the recipients for a message from a Sendmail-style
include file. This file must be called members.txt and it must live in the
list's data directory.
- >>> handler = config.handlers['file-recipients']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Short circuiting
@@ -22,6 +22,8 @@ returns.
... A message.
... """)
>>> msgdata = {'recips': 7}
+
+ >>> handler = config.handlers['file-recipients']
>>> handler.process(mlist, msg, msgdata)
>>> print msg.as_string()
From: aperson@example.com
diff --git a/src/mailman/pipeline/docs/nntp.txt b/src/mailman/pipeline/docs/nntp.txt
index dda104309..7b013aabf 100644
--- a/src/mailman/pipeline/docs/nntp.txt
+++ b/src/mailman/pipeline/docs/nntp.txt
@@ -6,10 +6,8 @@ Mailman has an NNTP gateway, whereby messages posted to the mailing list can
be forwarded onto an NNTP newsgroup. Typically this means Usenet, but since
NNTP is to Usenet as IP is to the web, it's more general than that.
- >>> handler = config.handlers['to-usenet']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
- >>> mlist.preferred_language = 'en'
- >>> switchboard = config.switchboards['news']
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Gatewaying from the mailing list to the newsgroup happens through a separate
'nntp' queue and happen immediately when the message is posted through to the
@@ -25,7 +23,11 @@ the newsgroup. The feature could be disabled, as is the default.
...
... Something of great import.
... """)
+
+ >>> handler = config.handlers['to-usenet']
>>> handler.process(mlist, msg, {})
+
+ >>> switchboard = config.switchboards['news']
>>> switchboard.files
[]
diff --git a/src/mailman/pipeline/docs/reply-to.txt b/src/mailman/pipeline/docs/reply-to.txt
index 2652753d6..18b821d7f 100644
--- a/src/mailman/pipeline/docs/reply-to.txt
+++ b/src/mailman/pipeline/docs/reply-to.txt
@@ -8,9 +8,8 @@ transformations. Some headers get added, others get changed. Some of these
changes depend on mailing list settings and others depend on how the message
is getting sent through the system. We'll take things one-by-one.
- >>> from mailman.pipeline.cook_headers import process
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
- >>> mlist.subject_prefix = ''
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Reply-to munging refers to the behavior where a mailing list can be configured
to change or augment an existing Reply-To header in a message posted to the
@@ -45,6 +44,8 @@ message, the list's posting address simply gets inserted.
... From: aperson@example.com
...
... """)
+
+ >>> from mailman.pipeline.cook_headers import process
>>> process(mlist, msg, {})
>>> len(msg.get_all('reply-to'))
1
diff --git a/src/mailman/pipeline/docs/scrubber.txt b/src/mailman/pipeline/docs/scrubber.txt
index 8bc33aa13..446843f51 100644
--- a/src/mailman/pipeline/docs/scrubber.txt
+++ b/src/mailman/pipeline/docs/scrubber.txt
@@ -7,8 +7,8 @@ messages and in components such as the archiver. Its primary purpose is to
scrub attachments from messages so that binary goop doesn't end up in an
archive message.
- >>> from mailman.pipeline.scrubber import process, save_attachment
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> mlist.preferred_language = 'en'
Helper functions for getting the attachment data.
@@ -41,7 +41,7 @@ Helper functions for getting the attachment data.
Saving attachments
==================
-The Scrubber handler exposes a function called save_attachments() which can be
+The Scrubber handler exposes a function called save_attachment() which can be
used to strip various types of attachments and store them in the archive
directory. This is a public interface used by components outside the normal
processing pipeline.
@@ -62,6 +62,8 @@ this is an unfortunate double negative).
...
... R0lGODdhAQABAIAAAAAAAAAAACwAAAAAAQABAAACAQUAOw==
... """)
+
+ >>> from mailman.pipeline.scrubber import save_attachment
>>> print save_attachment(mlist, msg, 'dir')
<http://www.example.com/pipermail/_xtest@example.com/dir/xtest.gif>
>>> data = read_attachment('dir/xtest.gif')
@@ -134,6 +136,7 @@ a reference to the attachment file as available through the on-line archive.
The Scrubber.process() function is different than other handler process
functions in that it returns the scrubbed message.
+ >>> from mailman.pipeline.scrubber import process
>>> scrubbed_msg = process(mlist, msg, msgdata)
>>> scrubbed_msg is msg
True
diff --git a/src/mailman/pipeline/docs/subject-munging.txt b/src/mailman/pipeline/docs/subject-munging.txt
index 68ad940e8..e7f55add6 100644
--- a/src/mailman/pipeline/docs/subject-munging.txt
+++ b/src/mailman/pipeline/docs/subject-munging.txt
@@ -8,9 +8,8 @@ transformations. Some headers get added, others get changed. Some of these
changes depend on mailing list settings and others depend on how the message
is getting sent through the system. We'll take things one-by-one.
- >>> from mailman.pipeline.cook_headers import process
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
- >>> mlist.subject_prefix = ''
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Inserting a prefix
@@ -29,6 +28,8 @@ munging, a mailing list must have a preferred language.
... A message of great import.
... """)
>>> msgdata = {}
+
+ >>> from mailman.pipeline.cook_headers import process
>>> process(mlist, msg, msgdata)
The original subject header is stored in the message metadata. We must print
diff --git a/src/mailman/pipeline/docs/tagger.txt b/src/mailman/pipeline/docs/tagger.txt
index a552401f7..46cdedcb7 100644
--- a/src/mailman/pipeline/docs/tagger.txt
+++ b/src/mailman/pipeline/docs/tagger.txt
@@ -9,8 +9,8 @@ double duty as the 'topic tag'. Each message that flows the mailing list has
its Subject: and Keywords: headers compared against these regular
expressions. The message then gets tagged with the topic names of each hit.
- >>> from mailman.pipeline.tagger import process
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Topics must be enabled for Mailman to do any topic matching, even if topics
are defined.
@@ -25,6 +25,8 @@ are defined.
...
... """)
>>> msgdata = {}
+
+ >>> from mailman.pipeline.tagger import process
>>> process(mlist, msg, msgdata)
>>> print msg.as_string()
Subject: foobar
diff --git a/src/mailman/pipeline/docs/to-outgoing.txt b/src/mailman/pipeline/docs/to-outgoing.txt
index 9d467bb5e..a8e67ec9f 100644
--- a/src/mailman/pipeline/docs/to-outgoing.txt
+++ b/src/mailman/pipeline/docs/to-outgoing.txt
@@ -10,10 +10,10 @@ term somewhat incorrectly, but within the spirit of the standard, which
basically describes how to encode the recipient's address in the originator
headers for unambigous bounce processing.
- >>> handler = config.handlers['to-outgoing']
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
- >>> switchboard = config.switchboards['out']
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
+ >>> switchboard = config.switchboards['out']
>>> def queue_size():
... size = len(switchboard.files)
... for filebase in switchboard.files:
@@ -34,6 +34,8 @@ When certain conditions are met, the message will be VERP'd. For example, if
the message metadata already has a VERP key, this message will be VERP'd.
>>> msgdata = dict(foo=1, bar=2, verp=True)
+
+ >>> handler = config.handlers['to-outgoing']
>>> handler.process(mlist, msg, msgdata)
>>> print msg.as_string()
Subject: Here is a message
diff --git a/src/mailman/queue/__init__.py b/src/mailman/queue/__init__.py
index ae3666643..a6ceb6bb2 100644
--- a/src/mailman/queue/__init__.py
+++ b/src/mailman/queue/__init__.py
@@ -52,6 +52,7 @@ from zope.interface import implements
from mailman import i18n
from mailman.config import config
from mailman.email.message import Message
+from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.runner import IRunner
from mailman.interfaces.switchboard import ISwitchboard
from mailman.utilities.filesystem import makedirs
@@ -417,7 +418,7 @@ class Runner:
#
# Find out which mailing list this message is destined for.
listname = unicode(msgdata.get('listname'))
- mlist = config.db.list_manager.get(listname)
+ mlist = IListManager(config).get(listname)
if mlist is None:
elog.error('Dequeuing message destined for missing list: %s',
listname)
diff --git a/src/mailman/queue/docs/news.txt b/src/mailman/queue/docs/news.txt
index c9f2417a0..a0535babc 100644
--- a/src/mailman/queue/docs/news.txt
+++ b/src/mailman/queue/docs/news.txt
@@ -7,8 +7,8 @@ NNTP newsgroup. One of the most important things this runner does is prepare
the message for Usenet (yes, I know that NNTP is not Usenet, but this runner
was originally written to gate to Usenet, which has its own rules).
- >>> from mailman.queue.news import prepare_message
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> mlist.linked_newsgroup = 'comp.lang.python'
Some NNTP servers such as INN reject messages containing a set of prohibited
@@ -33,6 +33,8 @@ prohibited headers.
... A message
... """)
>>> msgdata = {}
+
+ >>> from mailman.queue.news import prepare_message
>>> prepare_message(mlist, msg, msgdata)
>>> msgdata['prepped']
True
diff --git a/src/mailman/queue/docs/runner.txt b/src/mailman/queue/docs/runner.txt
index 032ea4c50..2c07f30ca 100644
--- a/src/mailman/queue/docs/runner.txt
+++ b/src/mailman/queue/docs/runner.txt
@@ -15,8 +15,8 @@ The basic architecture of qrunner is implemented in the base class that all
runners inherit from. This base class implements a .run() method that runs
continuously in a loop until the .stop() method is called.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
- >>> mlist.preferred_language = 'en'
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
Here is a very simple derived qrunner class. Queue runners use a
configuration section in the configuration files to determine run
diff --git a/src/mailman/queue/lmtp.py b/src/mailman/queue/lmtp.py
index 00c9ad988..a198f8850 100644
--- a/src/mailman/queue/lmtp.py
+++ b/src/mailman/queue/lmtp.py
@@ -41,6 +41,7 @@ from email.utils import parseaddr
from mailman.config import config
from mailman.database.transaction import txn
from mailman.email.message import Message
+from mailman.interfaces.listmanager import IListManager
from mailman.queue import Runner
elog = logging.getLogger('mailman.error')
@@ -133,7 +134,7 @@ class LMTPRunner(Runner, smtpd.SMTPServer):
try:
# Refresh the list of list names every time we process a message
# since the set of mailing lists could have changed.
- listnames = set(config.db.list_manager.names)
+ listnames = set(IListManager(config).names)
qlog.debug('listnames: %s', listnames)
# Parse the message data. If there are any defects in the
# message, reject it right away; it's probably spam.
diff --git a/src/mailman/rest/docs/lists.txt b/src/mailman/rest/docs/lists.txt
index 790ea02ba..ed9b3199b 100644
--- a/src/mailman/rest/docs/lists.txt
+++ b/src/mailman/rest/docs/lists.txt
@@ -54,7 +54,8 @@ instead of posting directly to the URL.
The mailing list exists in the database.
- >>> config.db.list_manager.get('test-two@example.com')
+ >>> from mailman.interfaces.listmanager import IListManager
+ >>> IListManager(config).get('test-two@example.com')
<mailing list "test-two@example.com" at ...>
# The above starts a Storm transaction, which will lock the database
diff --git a/src/mailman/rest/urls.py b/src/mailman/rest/urls.py
index a0b871aa0..6c455ceb9 100644
--- a/src/mailman/rest/urls.py
+++ b/src/mailman/rest/urls.py
@@ -33,6 +33,7 @@ from zope.traversing.browser.interfaces import IAbsoluteURL
from mailman.config import config
from mailman.core.system import system
+from mailman.interfaces.listmanager import IListManager
from mailman.rest.configuration import AdminWebServiceConfiguration
from mailman.rest.webservice import AdminWebServiceApplication
@@ -81,7 +82,7 @@ class FallbackURLMapper(BasicURLMapper):
return ''
urls = {
system: 'system',
- config.db.list_manager: 'lists',
+ IListManager(config): 'lists',
}
return urls[ob]
diff --git a/src/mailman/rest/webservice.py b/src/mailman/rest/webservice.py
index e1b5502d7..2d82c22a8 100644
--- a/src/mailman/rest/webservice.py
+++ b/src/mailman/rest/webservice.py
@@ -41,6 +41,7 @@ from zope.publisher.publish import publish
from mailman.config import config
from mailman.core.system import system
from mailman.interfaces.domain import IDomainCollection, IDomainManager
+from mailman.interfaces.listmanager import IListManager
from mailman.interfaces.rest import IResolvePathNames
from mailman.rest.publication import AdminWebServicePublication
@@ -79,7 +80,7 @@ class AdminWebServiceApplication:
top_level = dict(
system=system,
domains=IDomainCollection(IDomainManager(config)),
- lists=config.db.list_manager,
+ lists=IListManager(config),
)
next_step = top_level.get(name)
log.debug('Top level name: %s -> %s', name, next_step)
diff --git a/src/mailman/rules/docs/administrivia.txt b/src/mailman/rules/docs/administrivia.txt
index f43a31834..4da0a81b1 100644
--- a/src/mailman/rules/docs/administrivia.txt
+++ b/src/mailman/rules/docs/administrivia.txt
@@ -7,7 +7,8 @@ commands in the Subject header or first few lines of the payload. This is
used to catch messages posted to the list which should have been sent to the
-request robot address.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> mlist.administrivia = True
>>> rule = config.rules['administrivia']
>>> print rule.name
diff --git a/src/mailman/rules/docs/approve.txt b/src/mailman/rules/docs/approve.txt
index 8ae23b8f3..868827cf0 100644
--- a/src/mailman/rules/docs/approve.txt
+++ b/src/mailman/rules/docs/approve.txt
@@ -14,7 +14,8 @@ approval queue. This has several use cases:
In order to support this, a mailing list can be given a 'moderator password'
which is shared among all the administrators.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> mlist.moderator_password = 'abcxyz'
The 'approved' rule determines whether the message contains the proper
diff --git a/src/mailman/rules/docs/loop.txt b/src/mailman/rules/docs/loop.txt
index 5015d3d95..927df0e9b 100644
--- a/src/mailman/rules/docs/loop.txt
+++ b/src/mailman/rules/docs/loop.txt
@@ -5,7 +5,8 @@ Posting loops
To avoid a posting loop, Mailman has a rule to check for the existence of an
X-BeenThere header with the value of the list's posting address.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> rule = config.rules['loop']
>>> print rule.name
loop
diff --git a/src/mailman/rules/docs/max-size.txt b/src/mailman/rules/docs/max-size.txt
index a34c98627..264281b65 100644
--- a/src/mailman/rules/docs/max-size.txt
+++ b/src/mailman/rules/docs/max-size.txt
@@ -7,7 +7,8 @@ specified maximum. Generally this is used to prevent huge attachments from
getting posted to the list. This value is calculated in terms of KB (1024
bytes).
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> rule = config.rules['max-size']
>>> print rule.name
max-size
diff --git a/src/mailman/rules/docs/moderation.txt b/src/mailman/rules/docs/moderation.txt
index c4adcdf53..401e46605 100644
--- a/src/mailman/rules/docs/moderation.txt
+++ b/src/mailman/rules/docs/moderation.txt
@@ -7,7 +7,8 @@ postings, then only members with a cleared moderation flag will be able to
email the list without having those messages be held for approval. The
'moderation' rule determines whether the message should be moderated or not.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> rule = config.rules['moderation']
>>> print rule.name
moderation
diff --git a/src/mailman/rules/docs/news-moderation.txt b/src/mailman/rules/docs/news-moderation.txt
index 5658ccfef..269079505 100644
--- a/src/mailman/rules/docs/news-moderation.txt
+++ b/src/mailman/rules/docs/news-moderation.txt
@@ -9,7 +9,8 @@ posted to the newsgroup, and from there, gated to the mailing list. It's a
circuitous route, but it works nonetheless by holding all messages posted
directly to the mailing list.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> rule = config.rules['news-moderation']
>>> print rule.name
news-moderation
diff --git a/src/mailman/rules/docs/no-subject.txt b/src/mailman/rules/docs/no-subject.txt
index f9b3ece03..fa26006ef 100644
--- a/src/mailman/rules/docs/no-subject.txt
+++ b/src/mailman/rules/docs/no-subject.txt
@@ -5,7 +5,8 @@ No Subject header
This rule matches if the message has no Subject header, or if the header is
the empty string when stripped.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> rule = config.rules['no-subject']
>>> print rule.name
no-subject
diff --git a/src/mailman/rules/docs/recipients.txt b/src/mailman/rules/docs/recipients.txt
index e8c63b59a..724faa8ad 100644
--- a/src/mailman/rules/docs/recipients.txt
+++ b/src/mailman/rules/docs/recipients.txt
@@ -5,7 +5,8 @@ Maximum number of recipients
The 'max-recipients' rule matches when there are more than the maximum allowed
number of explicit recipients addressed by the message.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> rule = config.rules['max-recipients']
>>> print rule.name
max-recipients
diff --git a/src/mailman/rules/docs/rules.txt b/src/mailman/rules/docs/rules.txt
index 2836d10a1..a21816944 100644
--- a/src/mailman/rules/docs/rules.txt
+++ b/src/mailman/rules/docs/rules.txt
@@ -47,7 +47,8 @@ Individual rules can be checked to see if they match, by running the rule's
`check()` method. This returns a boolean indicating whether the rule was
matched or not.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> msg = message_from_string("""\
... From: aperson@example.com
...
diff --git a/src/mailman/rules/docs/suspicious.txt b/src/mailman/rules/docs/suspicious.txt
index 79d3eeea5..59b4493c4 100644
--- a/src/mailman/rules/docs/suspicious.txt
+++ b/src/mailman/rules/docs/suspicious.txt
@@ -6,7 +6,8 @@ Suspicious headers are a way for Mailman to hold messages that match a
particular regular expression. This mostly historical feature is fairly
confusing to users, and the list attribute that controls this is misnamed.
- >>> mlist = config.db.list_manager.create('_xtest@example.com')
+ >>> from mailman.app.lifecycle import create_list
+ >>> mlist = create_list('_xtest@example.com')
>>> rule = config.rules['suspicious-header']
>>> print rule.name
suspicious-header