diff options
| author | Barry Warsaw | 2008-01-14 23:22:15 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-01-14 23:22:15 -0500 |
| commit | 0bf7659000d2736839919c1ac2adc99b9bcb1b46 (patch) | |
| tree | 7ebc75fb36da6f5de9e8626ae5f05bc52bd81ac1 /Mailman/interfaces | |
| parent | a077406487020ecf8dfb7b27e931ca7eb9f5d3b2 (diff) | |
| download | mailman-0bf7659000d2736839919c1ac2adc99b9bcb1b46.tar.gz mailman-0bf7659000d2736839919c1ac2adc99b9bcb1b46.tar.zst mailman-0bf7659000d2736839919c1ac2adc99b9bcb1b46.zip | |
Use a more efficient way of deleting rows from a table, which coincidentally
<wink> works around the storm cache bug #178546.
Diffstat (limited to 'Mailman/interfaces')
| -rw-r--r-- | Mailman/interfaces/chain.py | 68 | ||||
| -rw-r--r-- | Mailman/interfaces/rules.py | 28 |
2 files changed, 68 insertions, 28 deletions
diff --git a/Mailman/interfaces/chain.py b/Mailman/interfaces/chain.py new file mode 100644 index 000000000..226ad232c --- /dev/null +++ b/Mailman/interfaces/chain.py @@ -0,0 +1,68 @@ +# 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. + +"""Interface describing the basics of chains and links.""" + +from munepy import Enum +from zope.interface import Interface, Attribute + + + +class IChain(Interface): + """A chain of rules.""" + + name = Attribute('Chain name; must be unique.') + description = Attribute('A brief description of the chain.') + + def process(mlist, msg, msgdata): + """Process the message through the chain. + + Processing a message involves running through each link in the chain, + until a jump to another chain occurs or the chain reaches the end. + Reaching the end of the chain with no other disposition is equivalent + to discarding the message. + + :param mlist: The mailing list object. + :param msg: The message object. + :param msgdata: The message metadata. + """ + + + +class IMutableChain(IChain): + """Like `IChain` but can be mutated.""" + + def append_link(link): + """Add a new chain link to the end of this chain. + + :param link: The chain link to add. + """ + + def flush(): + """Delete all links in this chain.""" + + + +class IChainLink(Interface): + """A link in the chain.""" + + rule = Attribute('The rule to run for this link.') + + jump = Attribute( + """The jump action to perform when the rule matches. This may be None + to simply process the next link in the chain. + """) diff --git a/Mailman/interfaces/rules.py b/Mailman/interfaces/rules.py index 5549b8e6b..24e479f81 100644 --- a/Mailman/interfaces/rules.py +++ b/Mailman/interfaces/rules.py @@ -21,11 +21,6 @@ from zope.interface import Interface, Attribute -class DuplicateRuleError(Exception): - """A rule or rule name is added to a processor more than once.""" - - - class IRule(Interface): """A basic rule.""" @@ -43,26 +38,3 @@ class IRule(Interface): :param msg: The message object. :param msgdata: The message metadata. """ - - - -class IRuleSet(Interface): - """A rule processor.""" - - rules = Attribute('The set of all rules this processor knows about.') - - def __getitem__(rule_name): - """Return the named rule. - - :param rule_name: The name of the rule. - :return: The IRule given by this name. - :raise: KeyError if no such rule is known by this processor. - """ - - def get(rule_name, default=None): - """Return the name rule. - - :param rule_name: The name of the rule. - :return: The IRule given by this name, or `default` if no such rule - is known by this processor. - """ |
