diff options
| author | Barry Warsaw | 2007-12-27 23:25:50 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2007-12-27 23:25:50 -0500 |
| commit | 306a1ceee0aad4c623f029d8809b40f7f55b9a6f (patch) | |
| tree | a880cc16e333a785fd3cdcd469dc388407568ba2 /Mailman/app/rules.py | |
| parent | 13dea3a6736834e19ad569b5e3d70a79e096a55e (diff) | |
| download | mailman-306a1ceee0aad4c623f029d8809b40f7f55b9a6f.tar.gz mailman-306a1ceee0aad4c623f029d8809b40f7f55b9a6f.tar.zst mailman-306a1ceee0aad4c623f029d8809b40f7f55b9a6f.zip | |
Change IRuleProcessor to IRuleSet. Plugins now provide only sets of rules,
they do not do the actual rule processing. That's left up to Mailman.
Further, the rule processor can be given a list of rules to run; those will be
the only ones run.
Diffstat (limited to '')
| -rw-r--r-- | Mailman/app/rules.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Mailman/app/rules.py b/Mailman/app/rules.py index 3e83eb60c..152694177 100644 --- a/Mailman/app/rules.py +++ b/Mailman/app/rules.py @@ -21,15 +21,26 @@ from Mailman.app.plugins import get_plugins -def process(mlist, msg, msgdata): +def process(mlist, msg, msgdata, rule_set=None): """Default rule processing plugin. + Rules are processed in random order so a rule should not permanently alter + a message or the message metadata. + :param msg: The message object. :param msgdata: The message metadata. + :param rule_set: The name of the rules to run. None (the default) means + to run all available rules. :return: A set of rule names that matched. """ - rule_hits = set() - for processor_class in get_plugins('mailman.rules'): - processor = processor_class() - rule_hits |= processor.process(mlist, msg, msgdata) - return rule_hits + # Collect all rules from all rule processors. + rules = set() + for rule_set_class in get_plugins('mailman.rules'): + rules |= set(rule for rule in rule_set_class().rules + if rule_set is None or rule.name in rule_set) + # Now process all rules, returning the set of rules that match. + rule_matches = set() + for rule in rules: + if rule.check(mlist, msg, msgdata): + rule_matches.add(rule.name) + return rule_matches |
