diff options
Diffstat (limited to 'src/mailman/app')
| -rw-r--r-- | src/mailman/app/docs/plugins.rst | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/src/mailman/app/docs/plugins.rst b/src/mailman/app/docs/plugins.rst index a66e4413d..4430179ae 100644 --- a/src/mailman/app/docs/plugins.rst +++ b/src/mailman/app/docs/plugins.rst @@ -117,7 +117,6 @@ initialization process. ... def rest_object(self): ... pass ... """, file=fp) - >>> fp.close() Running the hooks ----------------- @@ -143,12 +142,12 @@ script that will produce no output to force the hooks to run. >>> import subprocess >>> from mailman.testing.layers import ConfigLayer - >>> def call(): + >>> def call(cfg_path, python_path): ... exe = os.path.join(os.path.dirname(sys.executable), 'mailman') ... env = os.environ.copy() ... env.update( - ... MAILMAN_CONFIG_FILE=config_path, - ... PYTHONPATH=config_directory, + ... MAILMAN_CONFIG_FILE=cfg_path, + ... PYTHONPATH=python_path, ... ) ... test_cfg = os.environ.get('MAILMAN_EXTRA_TESTING_CFG') ... if test_cfg is not None: @@ -161,10 +160,51 @@ script that will produce no output to force the hooks to run. ... stdout, stderr = proc.communicate() ... assert proc.returncode == 0, stderr ... print(stdout) + ... print(stderr) - >>> call() + >>> call(config_path, config_directory) pre-hook: 1 post-hook: 2 <BLANKLINE> + <BLANKLINE> >>> os.remove(config_path) + +Deprecated hooks +---------------- + +The old-style `pre_hook` and `post_hook` callables are deprecated and are no +longer called upon startup. +:: + + >>> deprecated_hook_path = os.path.join(config_directory, 'deprecated_hooks.py') + >>> with open(deprecated_hook_path, 'w') as fp: + ... print("""\ + ... def do_something(): + ... print("does something") + ... + ... def do_something_else(): + ... print("does something else") + ... + ... """, file=fp) + + >>> deprecated_config_path = os.path.join(config_directory, 'deprecated.cfg') + >>> with open(deprecated_config_path, 'w') as fp: + ... print("""\ + ... [meta] + ... extends: test.cfg + ... + ... [mailman] + ... pre_hook: deprecated_hooks.do_something + ... post_hook: deprecated_hooks.do_something_else + ... """, file=fp) + + >>> call(deprecated_config_path, config_directory) + does something + does something else + <BLANKLINE> + ... UserWarning: The pre_hook configuration value has been replaced by the plugins infrastructure. ... + ... UserWarning: The post_hook configuration value has been replaced by the plugins infrastructure. ... + <BLANKLINE> + + >>> os.remove(deprecated_config_path) |
