summaryrefslogtreecommitdiff
path: root/src/mailman/chains/base.py
diff options
context:
space:
mode:
authorBarry Warsaw2017-08-04 01:13:04 +0000
committerBarry Warsaw2017-08-04 01:13:04 +0000
commit9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6 (patch)
treef021166b8c82bb02feff82a9360ba61a44b804ee /src/mailman/chains/base.py
parente6326533b78290514ede917ed1cb95804759a45a (diff)
downloadmailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.tar.gz
mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.tar.zst
mailman-9cdcffbc1189a19bc2963cf3d5c86a3d4f1f24a6.zip
Diffstat (limited to 'src/mailman/chains/base.py')
-rw-r--r--src/mailman/chains/base.py44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/mailman/chains/base.py b/src/mailman/chains/base.py
index 9507d8fbc..45301abc3 100644
--- a/src/mailman/chains/base.py
+++ b/src/mailman/chains/base.py
@@ -18,7 +18,6 @@
"""Base class for terminal chains."""
from mailman.config import config
-from mailman.core.i18n import _
from mailman.interfaces.chain import (
IChain, IChainIterator, IChainLink, IMutableChain, LinkAction)
from mailman.interfaces.rules import IRule
@@ -28,24 +27,6 @@ from zope.interface import implementer
@public
-def format_reasons(reasons):
- """Translate and format hold and rejection reasons.
-
- :param reasons: A list of reasons from the rules that hit. Each reason is
- a string to be translated or a tuple consisting of a string with {}
- replacements and one or more replacement values.
- :returns: A list of the translated and formatted strings.
- """
- new_reasons = []
- for reason in reasons:
- if isinstance(reason, tuple):
- new_reasons.append(_(reason[0]).format(*reason[1:]))
- else:
- new_reasons.append(_(reason))
- return new_reasons
-
-
-@public
@implementer(IChainLink)
class Link:
"""A chain link."""
@@ -107,6 +88,31 @@ class TerminalChainBase:
@public
@abstract_component
+@implementer(IChain)
+class JumpChainBase:
+ """A base chain that simplifies jumping to another chain."""
+ def jump_to(self, mlist, msg, msgsdata):
+ """Return the chain to jump to.
+
+ This must be overridden by subclasses.
+
+ :param mlist: The mailing list.
+ :param msg: The message.
+ :param msgdata: The message metadata.
+ :return: The name of the chain to jump to.
+ :rtype: str
+ """
+ raise NotImplementedError
+
+ def get_links(self, mlist, msg, msgdata):
+ jump_chain = self.jump_to(mlist, msg, msgdata)
+ return iter([
+ Link('truth', LinkAction.jump, jump_chain),
+ ])
+
+
+@public
+@abstract_component
@implementer(IMutableChain)
class Chain:
"""Generic chain base class."""