summaryrefslogtreecommitdiff
path: root/src/mailman/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/config')
-rw-r--r--src/mailman/config/config.py46
-rw-r--r--src/mailman/config/schema.cfg64
2 files changed, 93 insertions, 17 deletions
diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py
index 61c9fe6ed..c004d6e63 100644
--- a/src/mailman/config/config.py
+++ b/src/mailman/config/config.py
@@ -40,6 +40,19 @@ from zope.interface import implementer
SPACE = ' '
SPACERS = '\n'
+DIR_NAMES = (
+ 'archive',
+ 'bin',
+ 'cache',
+ 'data',
+ 'etc',
+ 'list_data',
+ 'lock',
+ 'log',
+ 'messages',
+ 'queue',
+ )
+
MAILMAN_CFG_TEMPLATE = """\
# AUTOMATICALLY GENERATED BY MAILMAN ON {} UTC
@@ -76,6 +89,7 @@ class Configuration:
self.handlers = {}
self.pipelines = {}
self.commands = {}
+ self.plugins = {}
self.password_context = None
self.db = None
@@ -158,8 +172,7 @@ class Configuration:
else category.template_dir),
)
# Directories.
- for name in ('archive', 'bin', 'cache', 'data', 'etc', 'ext',
- 'list_data', 'lock', 'log', 'messages', 'queue'):
+ for name in DIR_NAMES:
key = '{}_dir'.format(name)
substitutions[key] = getattr(category, key)
# Files.
@@ -248,6 +261,35 @@ class Configuration:
yield archiver
@property
+ def plugin_configs(self):
+ """Return all the plugin configuration sections."""
+ plugin_sections = self._config.getByCategory('plugin', [])
+ for section in plugin_sections:
+ # 2017-08-27 barry: There's a fundamental constraint imposed by
+ # lazr.config, namely that we have to use a .master section instead
+ # of a .template section in the schema.cfg, or user supplied
+ # configuration files cannot define new [plugin.*] sections. See
+ # https://bugs.launchpad.net/lazr.config/+bug/310619 for
+ # additional details.
+ #
+ # However, this means that [plugin.master] will show up in the
+ # categories retrieved above. But 'master' is not a real plugin,
+ # so we need to skip it (e.g. otherwise we'll get log warnings
+ # about plugin.master being disabled, etc.). This imposes an
+ # additional limitation though in that users cannot define a
+ # plugin named 'master' because you can't override a master
+ # section with a real section. There's no good way around this so
+ # we just have to live with this limitation.
+ if section.name == 'plugin.master':
+ continue
+ # The section.name will be something like 'plugin.example', but we
+ # only want the 'example' part as the name of the plugin. We
+ # could split on dots, but lazr.config gives us a different way.
+ # `category_and_section_names` is a 2-tuple of e.g.
+ # ('plugin', 'example'), so just grab the last element.
+ yield section.category_and_section_names[1], section
+
+ @property
def language_configs(self):
"""Iterate over all the language configuration sections."""
yield from self._config.getByCategory('language', [])
diff --git a/src/mailman/config/schema.cfg b/src/mailman/config/schema.cfg
index 9568694be..b6f99c61d 100644
--- a/src/mailman/config/schema.cfg
+++ b/src/mailman/config/schema.cfg
@@ -54,14 +54,6 @@ pending_request_life: 3d
# How long should files be saved before they are evicted from the cache?
cache_life: 7d
-# A callable to run with no arguments early in the initialization process.
-# This runs before database initialization.
-pre_hook:
-
-# A callable to run with no arguments late in the initialization process.
-# This runs after adapters are initialized.
-post_hook:
-
# Which paths.* file system layout to use.
layout: here
@@ -82,6 +74,51 @@ html_to_plain_text_command: /usr/bin/lynx -dump $filename
# unpredictable.
listname_chars: [-_.0-9a-z]
+# These hooks are deprecated, but are kept here so as not to break existing
+# configuration files. However, these hooks are not run. Define a plugin
+# instead.
+pre_hook:
+post_hook:
+
+
+# Plugin configuration section template.
+#
+# To add a plugin, instantiate this section (changing `master` to whatever
+# your plugin's name is), and define at least a `path` and a `class`. When
+# the plugin is loaded, its subpackages will be search for components matching
+# the following interfaces:
+#
+# - IChain for new chains
+# - ICliSubCommand - `mailman` subcommands
+# - IEmailCommand - new email commands
+# - IHandler for new handlers
+# - IPipeline for new pipelines
+# - IRule for new rules
+# - IStyle for new styles.
+#
+# See the IPlugin interface for more details.
+[plugin.master]
+
+# The full Python import path for you IPlugin implementing class. It is
+# required to provide this.
+class:
+
+# Whether to enable this plugin or not.
+enabled: no
+
+# Additional configuration file for this plugin. If the value starts with
+# `python:` it is a Python import path, in which case the value should not
+# include the trailing .cfg (although the file is required to have this
+# suffix). Without `python:`, it is a file system path, and must be an
+# absolute path, since no guarantees are made about the current working
+# directory.
+configuration:
+
+# Package (as a dotted Python import path) to search for components that this
+# plugin wants to add, such as ISTyles, IRules, etc. If not given, the
+# plugin's name is used.
+component_package:
+
[shell]
# `mailman shell` (also `withlist`) gives you an interactive prompt that you
@@ -138,8 +175,6 @@ data_dir: $var_dir/data
cache_dir: $var_dir/cache
# Directory for configuration files and such.
etc_dir: $var_dir/etc
-# Directory containing Mailman plugins.
-ext_dir: $var_dir/ext
# Directory where the default IMessageStore puts its messages.
messages_dir: $var_dir/messages
# Directory for archive backends to store their messages in. Archivers should
@@ -261,6 +296,7 @@ debug: no
# - http -- Internal wsgi-based web interface
# - locks -- Lock state changes
# - mischief -- Various types of hostile activity
+# - plugins -- Plugin logs
# - runner -- Runner process start/stops
# - smtp -- Successful SMTP activity
# - smtp-failure -- Unsuccessful SMTP activity
@@ -298,6 +334,9 @@ level: info
[logging.mischief]
+[logging.plugins]
+path: plugins.log
+
[logging.runner]
[logging.smtp]
@@ -797,11 +836,6 @@ class: mailman.archiving.prototype.Prototype
[styles]
-# Python import paths inside which components are searched for which implement
-# the IStyle interface. Use one path per line.
-paths:
- mailman.styles
-
# The default style to apply if nothing else was requested. The value is the
# name of an existing style. If no such style exists, no style will be
# applied.