diff options
| author | Barry Warsaw | 2017-08-29 14:07:55 +0000 |
|---|---|---|
| committer | Barry Warsaw | 2017-08-29 14:07:55 +0000 |
| commit | de8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c (patch) | |
| tree | 6fd2038427fbb36d8173fe338d277351cd19727b /src/mailman/config/config.py | |
| parent | f847e15407bfbf824236547bdf728a1ae00bd405 (diff) | |
| parent | ae0042a90220119414f61aeb20c6b58bfacb8af2 (diff) | |
| download | mailman-de8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c.tar.gz mailman-de8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c.tar.zst mailman-de8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c.zip | |
Diffstat (limited to 'src/mailman/config/config.py')
| -rw-r--r-- | src/mailman/config/config.py | 46 |
1 files changed, 44 insertions, 2 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', []) |
