summaryrefslogtreecommitdiff
path: root/src/mailman/core
diff options
context:
space:
mode:
authorBarry Warsaw2010-12-28 13:14:41 -0500
committerBarry Warsaw2010-12-28 13:14:41 -0500
commitc89087190a641da1353b394a722cf9cee3792394 (patch)
tree4dc1dddcd9fe51d5c11b70f5b50171738563f359 /src/mailman/core
parent871fe5390bf5c1c6f636ec846b870bdcff86aeaf (diff)
parent13cf4e754334b690711511291f72ae8cc0a7ab16 (diff)
downloadmailman-c89087190a641da1353b394a722cf9cee3792394.tar.gz
mailman-c89087190a641da1353b394a722cf9cee3792394.tar.zst
mailman-c89087190a641da1353b394a722cf9cee3792394.zip
This is part 1 of the merge of Jimmy Bergman's branch
lp:~jimmy-sigint/mailman/restapi_additional_attributes Ostensibly, this adds support for a few additional attributes through the REST API: * default_member_moderation * generic_nonmember_action * member_moderation_action * reply_goes_to_list * send_welcome_msg * welcome_msg However, I had never previously fleshed out the conversion of default_member_moderation and member_moderation_action into the MM3 way of things. That is now done. Non-member moderation still needs to be done. Specific changes: * mailman.chains.base.Chain no longer self registers * The built-in chain gets a new link for checking 'member-moderation'. If this rule matches, it jumps to the 'member-moderation' chain, which checks member_moderation_action and returns a link that jumps to the appropriate terminal chain. * Chain initialization is done by the same auto-detection as rules, handlers, etc. The one tricky thing is that abstract base classes such as Chain and TerminalChainBase can't be instantiated. For now, there's an ugly special case to skip these. * default_member_moderation is now exposed in the IMailingList interface. * Member.is_moderated gets set in the constructor from the mailing list's default_member_moderation. * The 'moderation' rule is renamed 'member-moderation'. TODO: * Work out non-member moderation * Add member_moderation_action to IMailingList * Double check tests for reply_goes_to_list, send_welcome_msg, and welcome_msg
Diffstat (limited to 'src/mailman/core')
-rw-r--r--src/mailman/core/chains.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mailman/core/chains.py b/src/mailman/core/chains.py
index 35e886d69..a81cbeedc 100644
--- a/src/mailman/core/chains.py
+++ b/src/mailman/core/chains.py
@@ -26,14 +26,12 @@ __all__ = [
]
-from mailman.chains.accept import AcceptChain
-from mailman.chains.builtin import BuiltInChain
-from mailman.chains.discard import DiscardChain
-from mailman.chains.headers import HeaderMatchChain
-from mailman.chains.hold import HoldChain
-from mailman.chains.reject import RejectChain
+from zope.interface.verify import verifyObject
+
+from mailman.app.finder import find_components
+from mailman.chains.base import Chain, TerminalChainBase
from mailman.config import config
-from mailman.interfaces.chain import LinkAction
+from mailman.interfaces.chain import LinkAction, IChain
@@ -67,7 +65,6 @@ def process(mlist, msg, msgdata, start_chain='built-in'):
return
chain, chain_iter = chain_stack.pop()
continue
- # Process this link.
if link.rule.check(mlist, msg, msgdata):
if link.rule.record:
hits.append(link.rule.name)
@@ -103,16 +100,19 @@ def process(mlist, msg, msgdata, start_chain='built-in'):
def initialize():
"""Set up chains, both built-in and from the database."""
- for chain_class in (DiscardChain, HoldChain, RejectChain, AcceptChain):
+ for chain_class in find_components('mailman.chains', IChain):
+ # FIXME 2010-12-28 barry: We need a generic way to disable automatic
+ # instantiation of discovered classes. This is useful not just for
+ # chains, but also for rules, handlers, etc. Ideally it should be
+ # part of find_components(). For now, hard code the ones we do not
+ # want to instantiate.
+ if chain_class in (Chain, TerminalChainBase):
+ continue
chain = chain_class()
+ verifyObject(IChain, chain)
assert chain.name not in config.chains, (
- 'Duplicate chain name: {0}'.format(chain.name))
+ 'Duplicate chain "{0}" found in {1} (previously: {2}'.format(
+ chain.name, chain_class, config.chains[chain.name]))
config.chains[chain.name] = chain
- # Set up a couple of other default chains.
- chain = BuiltInChain()
- config.chains[chain.name] = chain
- # Create and initialize the header matching chain.
- chain = HeaderMatchChain()
- config.chains[chain.name] = chain
# XXX Read chains from the database and initialize them.
pass