diff options
| author | Barry Warsaw | 2008-01-23 23:47:50 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-01-23 23:47:50 -0500 |
| commit | df637148d8fa2d5c101a990ee6766ea8547f000a (patch) | |
| tree | 92e3e1c218c6f59031a0d0383a98a38e38dc2f9f /Mailman/rules | |
| parent | 4460aad316db5c8af9b84c392e67441acaac9d72 (diff) | |
| download | mailman-df637148d8fa2d5c101a990ee6766ea8547f000a.tar.gz mailman-df637148d8fa2d5c101a990ee6766ea8547f000a.tar.zst mailman-df637148d8fa2d5c101a990ee6766ea8547f000a.zip | |
More changes to rules and chains.
Now a link has a rule, action, chain, and function, not all of which needs to
be specified. The action is a LinkAction enum adn specifies what to do should
the rule match. The use of the chain or function depends on what the action
is.
Several interface changes now make it easier to jump to other chains, push
(i.e. detour) to chains, etc. Rules can also now specify that they should not
be recorded in X-* headers.
Added a TruthRule which always matches.
Diffstat (limited to 'Mailman/rules')
| -rw-r--r-- | Mailman/rules/administrivia.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/any.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/approved.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/docs/emergency.txt | 13 | ||||
| -rw-r--r-- | Mailman/rules/docs/rules.txt | 1 | ||||
| -rw-r--r-- | Mailman/rules/emergency.py | 10 | ||||
| -rw-r--r-- | Mailman/rules/implicit_dest.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/loop.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/max_recipients.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/max_size.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/moderation.py | 4 | ||||
| -rw-r--r-- | Mailman/rules/news_moderation.py | 10 | ||||
| -rw-r--r-- | Mailman/rules/no_subject.py | 3 | ||||
| -rw-r--r-- | Mailman/rules/suspicious.py | 3 |
14 files changed, 39 insertions, 26 deletions
diff --git a/Mailman/rules/administrivia.py b/Mailman/rules/administrivia.py index 589c4a56b..76848fecf 100644 --- a/Mailman/rules/administrivia.py +++ b/Mailman/rules/administrivia.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -55,6 +55,7 @@ class Administrivia: name = 'administrivia' description = _('Catch mis-addressed email commands.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/any.py b/Mailman/rules/any.py index b97ad73d2..c0755b58f 100644 --- a/Mailman/rules/any.py +++ b/Mailman/rules/any.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -34,6 +34,7 @@ class Any: name = 'any' description = _('Look for any previous rule hit.') + record = False def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/approved.py b/Mailman/rules/approved.py index 98b158dd9..f3c1dc412 100644 --- a/Mailman/rules/approved.py +++ b/Mailman/rules/approved.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -39,6 +39,7 @@ class Approved: name = 'approved' description = _('The message has a matching Approve or Approved header.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/docs/emergency.txt b/Mailman/rules/docs/emergency.txt index 685d7bcb6..1375c3bc9 100644 --- a/Mailman/rules/docs/emergency.txt +++ b/Mailman/rules/docs/emergency.txt @@ -16,15 +16,12 @@ list are held for moderator approval. ... An important message. ... """) -The emergency rule is matched as part of the built-in chain. - - >>> from Mailman.configuration import config - >>> chain = config.chains['built-in'] - -The emergency rule matches if the flag is set on the mailing list. +The emergency rule is matched as part of the built-in chain. The emergency +rule matches if the flag is set on the mailing list. + >>> from Mailman.app.chains import process >>> mlist.emergency = True - >>> chain.process(mlist, msg, {}) + >>> process('built-in', mlist, msg, {}) There are two messages in the virgin queue. The one addressed to the original sender will contain a token we can use to grab the held message out of the @@ -72,6 +69,6 @@ However, if the message metadata has a 'moderator_approved' key set, then even if the mailing list has its emergency flag set, the message still goes through to the membership. - >>> chain.process(mlist, msg, dict(moderator_approved=True)) + >>> process('built-in', mlist, msg, dict(moderator_approved=True)) >>> len(virginq.files) 0 diff --git a/Mailman/rules/docs/rules.txt b/Mailman/rules/docs/rules.txt index 1f5b147e7..d2d291331 100644 --- a/Mailman/rules/docs/rules.txt +++ b/Mailman/rules/docs/rules.txt @@ -31,6 +31,7 @@ names to rule objects. no-subject True non-member True suspicious-header True + truth True You can get a rule by name. diff --git a/Mailman/rules/emergency.py b/Mailman/rules/emergency.py index 0e6aa97b4..6d924b399 100644 --- a/Mailman/rules/emergency.py +++ b/Mailman/rules/emergency.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -33,9 +33,11 @@ class Emergency: implements(IRule) name = 'emergency' - description = _("""\ -The mailing list is in emergency hold and this message was not pre-approved by -the list administrator.""") + description = _( + """The mailing list is in emergency hold and this message was not + pre-approved by the list administrator. + """) + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/implicit_dest.py b/Mailman/rules/implicit_dest.py index 19a096aa5..1b459caed 100644 --- a/Mailman/rules/implicit_dest.py +++ b/Mailman/rules/implicit_dest.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -36,6 +36,7 @@ class ImplicitDestination: name = 'implicit-dest' description = _('Catch messages with implicit destination.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/loop.py b/Mailman/rules/loop.py index a88858d6a..93bd1241d 100644 --- a/Mailman/rules/loop.py +++ b/Mailman/rules/loop.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -34,6 +34,7 @@ class Loop: name = 'loop' description = _("""Look for a posting loop, via the X-BeenThere header.""") + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/max_recipients.py b/Mailman/rules/max_recipients.py index dfa23f659..e4fb3faf3 100644 --- a/Mailman/rules/max_recipients.py +++ b/Mailman/rules/max_recipients.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -35,6 +35,7 @@ class MaximumRecipients: name = 'max-recipients' description = _('Catch messages with too many explicit recipients.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/max_size.py b/Mailman/rules/max_size.py index b723fbf07..e54b68c9c 100644 --- a/Mailman/rules/max_size.py +++ b/Mailman/rules/max_size.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -34,6 +34,7 @@ class MaximumSize: name = 'max-size' description = _('Catch messages that are bigger than a specified maximum.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/moderation.py b/Mailman/rules/moderation.py index 9fa7cd34d..29a478662 100644 --- a/Mailman/rules/moderation.py +++ b/Mailman/rules/moderation.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -37,6 +37,7 @@ class Moderation: name = 'moderation' description = _('Match messages sent by moderated members.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" @@ -54,6 +55,7 @@ class NonMember: name = 'non-member' description = _('Match messages sent by non-members.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/news_moderation.py b/Mailman/rules/news_moderation.py index 9caf8fb4a..56c9fef37 100644 --- a/Mailman/rules/news_moderation.py +++ b/Mailman/rules/news_moderation.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -33,9 +33,11 @@ class ModeratedNewsgroup: implements(IRule) name = 'news-moderation' - description = _(u"""\ -Match all messages posted to a mailing list that gateways to a moderated -newsgroup.""") + description = _( + u"""Match all messages posted to a mailing list that gateways to a + moderated newsgroup. + """) + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/no_subject.py b/Mailman/rules/no_subject.py index c36d742b8..4a8c6ac99 100644 --- a/Mailman/rules/no_subject.py +++ b/Mailman/rules/no_subject.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -34,6 +34,7 @@ class NoSubject: name = 'no-subject' description = _('Catch messages with no, or empty, Subject headers.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" diff --git a/Mailman/rules/suspicious.py b/Mailman/rules/suspicious.py index 0464a6336..4936734e5 100644 --- a/Mailman/rules/suspicious.py +++ b/Mailman/rules/suspicious.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007 by the Free Software Foundation, Inc. +# Copyright (C) 2007-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -36,6 +36,7 @@ class SuspiciousHeader: name = 'suspicious-header' description = _('Catch messages with suspicious headers.') + record = True def check(self, mlist, msg, msgdata): """See `IRule`.""" |
