summaryrefslogtreecommitdiff
path: root/src/mailman/core
diff options
context:
space:
mode:
authorJ08nY2017-05-31 02:09:09 +0200
committerJ08nY2017-08-07 17:39:07 +0200
commit38a86adcdb78c1944c26a5ab8deddff619b33bcf (patch)
treec9b6f8810e33657161535bb887829305306ce0f2 /src/mailman/core
parent324226f1f859f6be5e932dc9abe638aba268d154 (diff)
downloadmailman-38a86adcdb78c1944c26a5ab8deddff619b33bcf.tar.gz
mailman-38a86adcdb78c1944c26a5ab8deddff619b33bcf.tar.zst
mailman-38a86adcdb78c1944c26a5ab8deddff619b33bcf.zip
Add pluggable components.
- Adds the notion of a 'plugin'. - A plugin has a package path and a flag specifying whether it's enabled or not. - Adds a find_pluggable_components function similar to the find_components one. This one dynamically searches not only the mailman package but all of plugins. - e.g. find_pluggable_components('rules', IRule) finds all IRule components in mailman.rules but also in example_plugin.rules for plugin names example_plugin. - Uses the find_pluggable_components function in place of find_components when searching for Rules, Handlers, Chains, EmailCommands, and Styles.
Diffstat (limited to 'src/mailman/core')
-rw-r--r--src/mailman/core/chains.py5
-rw-r--r--src/mailman/core/pipelines.py6
-rw-r--r--src/mailman/core/rules.py4
3 files changed, 7 insertions, 8 deletions
diff --git a/src/mailman/core/chains.py b/src/mailman/core/chains.py
index c251d38bc..48ed82d63 100644
--- a/src/mailman/core/chains.py
+++ b/src/mailman/core/chains.py
@@ -19,7 +19,7 @@
from mailman.config import config
from mailman.interfaces.chain import IChain, LinkAction
-from mailman.utilities.modules import add_components
+from mailman.utilities.plugins import add_pluggable_components
from public import public
@@ -89,5 +89,4 @@ def process(mlist, msg, msgdata, start_chain='default-posting-chain'):
@public
def initialize():
"""Set up chains, both built-in and from the database."""
- add_components('mailman.chains', IChain, config.chains)
- # XXX Read chains from the database and initialize them.
+ add_pluggable_components('chains', IChain, config.chains)
diff --git a/src/mailman/core/pipelines.py b/src/mailman/core/pipelines.py
index 4265d24d1..6e2ad4a27 100644
--- a/src/mailman/core/pipelines.py
+++ b/src/mailman/core/pipelines.py
@@ -24,7 +24,7 @@ from mailman.config import config
from mailman.interfaces.handler import IHandler
from mailman.interfaces.pipeline import (
DiscardMessage, IPipeline, RejectMessage)
-from mailman.utilities.modules import add_components
+from mailman.utilities.plugins import add_pluggable_components
from public import public
@@ -63,6 +63,6 @@ def process(mlist, msg, msgdata, pipeline_name='built-in'):
def initialize():
"""Initialize the pipelines."""
# Find all handlers in the registered plugins.
- add_components('mailman.handlers', IHandler, config.handlers)
+ add_pluggable_components('handlers', IHandler, config.handlers)
# Set up some pipelines.
- add_components('mailman.pipelines', IPipeline, config.pipelines)
+ add_pluggable_components('pipelines', IPipeline, config.pipelines)
diff --git a/src/mailman/core/rules.py b/src/mailman/core/rules.py
index 8e0d9197c..74934eb99 100644
--- a/src/mailman/core/rules.py
+++ b/src/mailman/core/rules.py
@@ -19,7 +19,7 @@
from mailman.config import config
from mailman.interfaces.rules import IRule
-from mailman.utilities.modules import add_components
+from mailman.utilities.plugins import add_pluggable_components
from public import public
@@ -27,4 +27,4 @@ from public import public
def initialize():
"""Find and register all rules in all plugins."""
# Find rules in plugins.
- add_components('mailman.rules', IRule, config.rules)
+ add_pluggable_components('rules', IRule, config.rules)