From 6c58abe8a135bd8f572867c170fed19958ca9a09 Mon Sep 17 00:00:00 2001 From: J08nY Date: Thu, 1 Jun 2017 15:46:48 +0200 Subject: Add per-plugin hooks, add docs about plugins. - Removes pre_hook, post_hook and ext_dir. With the latter being unused. Warns on startup if the hooks are present in config. - Adds IPlugin interface with pre_hook and post_hook methods. - Adds 'class' config parameter to plugins, which can be set to a class implementing the IPlugin interface, it will be initialized once on Mailman's startup, then before the DB setup the pre_hook will be run, after DB and other components the post_hook will be run. Plugin instances are stored in the config.plugins dict, with keys being their configuration section names. --- src/mailman/testing/plugin.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/mailman/testing/plugin.py (limited to 'src/mailman/testing/plugin.py') diff --git a/src/mailman/testing/plugin.py b/src/mailman/testing/plugin.py new file mode 100644 index 000000000..75667844a --- /dev/null +++ b/src/mailman/testing/plugin.py @@ -0,0 +1,36 @@ +# Copyright (C) 2009-2017 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see . + +"""Example plugin with hooks for testing purposes.""" + +from mailman.interfaces.plugin import IPlugin +from public import public +from zope.interface import implementer + + +@public +@implementer(IPlugin) +class ExamplePlugin: + + def __init__(self): + pass + + def pre_hook(self): + pass + + def post_hook(self): + pass -- cgit v1.2.3-70-g09d2