From f3ee1ed7d9198d79f7feaf6fb3bb5b6e5ae4bd38 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 3 Mar 2009 00:31:03 -0500 Subject: Convert content filter and acceptable aliases away from pickle types. * Add an adapter from mailing lists to acceptable alias set. Use this instead of the old acceptable alias interface, which is not removed. * Add contentfilter table * Add a bunch of missing docstrings --- src/mailman/rules/docs/implicit-dest.txt | 20 +++++++++++++------- src/mailman/rules/implicit_dest.py | 5 ++++- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/mailman/rules') diff --git a/src/mailman/rules/docs/implicit-dest.txt b/src/mailman/rules/docs/implicit-dest.txt index c0439cfca..8666c1f5c 100644 --- a/src/mailman/rules/docs/implicit-dest.txt +++ b/src/mailman/rules/docs/implicit-dest.txt @@ -9,11 +9,17 @@ not explicitly mentioned in the set of message recipients. >>> print rule.name implicit-dest +In order to check for implicit destinations, we need to adapt the mailing list +to the appropriate interface. + + >>> from mailman.interfaces.mailinglist import IAcceptableAliasSet + >>> alias_set = IAcceptableAliasSet(mlist) + This rule matches messages that have an implicit destination, meaning that the mailing list's posting address isn't included in the explicit recipients. >>> mlist.require_explicit_destination = True - >>> mlist.clear_acceptable_aliases() + >>> alias_set.clear() >>> msg = message_from_string("""\ ... From: aperson@example.org @@ -50,7 +56,7 @@ then the rule will not match. >>> rule.check(mlist, msg, {}) True - >>> mlist.add_acceptable_alias(u'myfriend@example.com') + >>> alias_set.add(u'myfriend@example.com') >>> rule.check(mlist, msg, {}) False @@ -63,7 +69,7 @@ that Mailman pulled it from the appropriate news group. Additional aliases can be added. - >>> mlist.add_acceptable_alias(u'other@example.com') + >>> alias_set.add(u'other@example.com') >>> del msg['to'] >>> rule.check(mlist, msg, {}) True @@ -74,7 +80,7 @@ Additional aliases can be added. Aliases can be removed. - >>> mlist.remove_acceptable_alias(u'other@example.com') + >>> alias_set.remove(u'other@example.com') >>> rule.check(mlist, msg, {}) True @@ -84,7 +90,7 @@ Aliases can also be cleared. >>> rule.check(mlist, msg, {}) False - >>> mlist.clear_acceptable_aliases() + >>> alias_set.clear() >>> rule.check(mlist, msg, {}) True @@ -96,7 +102,7 @@ It's also possible to specify an alias pattern, i.e. a regular expression to match against the recipients. For example, we can say that if there is a recipient in the example.net domain, then the rule does not match. - >>> mlist.add_acceptable_alias(u'^.*@example.net') + >>> alias_set.add(u'^.*@example.net') >>> rule.check(mlist, msg, {}) True @@ -111,7 +117,7 @@ Bad aliases You cannot add an alias that looks like neither a pattern nor an email address. - >>> mlist.add_acceptable_alias('foobar') + >>> alias_set.add('foobar') Traceback (most recent call last): ... ValueError: foobar diff --git a/src/mailman/rules/implicit_dest.py b/src/mailman/rules/implicit_dest.py index 69e6f8434..f2e1f5446 100644 --- a/src/mailman/rules/implicit_dest.py +++ b/src/mailman/rules/implicit_dest.py @@ -30,6 +30,7 @@ from email.utils import getaddresses from zope.interface import implements from mailman.i18n import _ +from mailman.interfaces.mailinglist import IAcceptableAliasSet from mailman.interfaces.rules import IRule @@ -55,7 +56,9 @@ class ImplicitDestination: # a caret (i.e. ^), then it's a regular expression to match against. aliases = set() alias_patterns = set() - for alias in mlist.acceptable_aliases: + # Adapt the mailing list to the appropriate interface. + alias_set = IAcceptableAliasSet(mlist) + for alias in alias_set.aliases: if alias.startswith('^'): alias_patterns.add(alias) else: -- cgit v1.2.3-70-g09d2