summaryrefslogtreecommitdiff
path: root/Mailman/app/rules.py
diff options
context:
space:
mode:
authorBarry Warsaw2008-01-23 23:47:50 -0500
committerBarry Warsaw2008-01-23 23:47:50 -0500
commitdf637148d8fa2d5c101a990ee6766ea8547f000a (patch)
tree92e3e1c218c6f59031a0d0383a98a38e38dc2f9f /Mailman/app/rules.py
parent4460aad316db5c8af9b84c392e67441acaac9d72 (diff)
downloadmailman-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 '')
-rw-r--r--Mailman/app/rules.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Mailman/app/rules.py b/Mailman/app/rules.py
index a3846541e..f0209c767 100644
--- a/Mailman/app/rules.py
+++ b/Mailman/app/rules.py
@@ -18,10 +18,13 @@
"""Various rule helpers"""
__all__ = [
+ 'TruthRule',
'initialize',
]
+__metaclass__ = type
+from zope.interface import implements
from zope.interface.verify import verifyObject
from Mailman.app.plugins import get_plugins
@@ -30,8 +33,25 @@ from Mailman.interfaces import IRule
+class TruthRule:
+ """A rule that always matches."""
+ implements(IRule)
+
+ name = 'truth'
+ description = 'A rule which always matches.'
+ record = False
+
+ def check(self, mlist, msg, msgdata):
+ """See `IRule`."""
+ return True
+
+
+
def initialize():
"""Find and register all rules in all plugins."""
+ # Register built in rules.
+ config.rules[TruthRule.name] = TruthRule()
+ # Find rules in plugins.
for rule_finder in get_plugins('mailman.rules'):
for rule_class in rule_finder():
rule = rule_class()