summaryrefslogtreecommitdiff
path: root/Mailman/app/rules.py
diff options
context:
space:
mode:
authorBarry Warsaw2007-12-27 23:04:08 -0500
committerBarry Warsaw2007-12-27 23:04:08 -0500
commit13dea3a6736834e19ad569b5e3d70a79e096a55e (patch)
treeab8448fd114436cd1dc9a1754ce8c9c7dfc865d4 /Mailman/app/rules.py
parent7923b90f0349f9e2dc891082e2e1c3bf23b4d79c (diff)
downloadmailman-13dea3a6736834e19ad569b5e3d70a79e096a55e.tar.gz
mailman-13dea3a6736834e19ad569b5e3d70a79e096a55e.tar.zst
mailman-13dea3a6736834e19ad569b5e3d70a79e096a55e.zip
First cut at a rules processor, separate from the disposition of rule hits.
The basic idea is that we process rules on a mlist, message, metadata triplet making a list of all rules that hit. Then a different part of the system will decide on the disposition of a message based on which rules hit and their priority. The doctest and plugin architecture is in place, including the tie-in to setup.py. Ported the first rule -- emergency.py -- to the new rule processor. We no longer need SQLAlchemy as a requirement, and the setuptools/bzr plugin name has changed.
Diffstat (limited to '')
-rw-r--r--Mailman/app/rules.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Mailman/app/rules.py b/Mailman/app/rules.py
new file mode 100644
index 000000000..3e83eb60c
--- /dev/null
+++ b/Mailman/app/rules.py
@@ -0,0 +1,35 @@
+# Copyright (C) 2007 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
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+"""Process all rules defined by entry points."""
+
+from Mailman.app.plugins import get_plugins
+
+
+
+def process(mlist, msg, msgdata):
+ """Default rule processing plugin.
+
+ :param msg: The message object.
+ :param msgdata: The message metadata.
+ :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