diff options
| author | J08nY | 2017-07-25 21:44:54 +0200 |
|---|---|---|
| committer | J08nY | 2017-08-07 17:39:08 +0200 |
| commit | 8addebbf9802e911c06f6a27b7ffff1e0f1d2e57 (patch) | |
| tree | 392b50bf726d790102a6036b7aae7e3aa4228720 /src/mailman/core/initialize.py | |
| parent | cc99242654f2bcc11b3a6f124908de4b175c48d4 (diff) | |
| download | mailman-pluggable-components.tar.gz mailman-pluggable-components.tar.zst mailman-pluggable-components.zip | |
Diffstat (limited to 'src/mailman/core/initialize.py')
| -rw-r--r-- | src/mailman/core/initialize.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/mailman/core/initialize.py b/src/mailman/core/initialize.py index a1314b51e..830bd9b84 100644 --- a/src/mailman/core/initialize.py +++ b/src/mailman/core/initialize.py @@ -31,7 +31,9 @@ import traceback import mailman.config.config import mailman.core.logging +from mailman.core.i18n import _ from mailman.interfaces.database import IDatabaseFactory +from mailman.utilities.modules import call_name from pkg_resources import resource_string as resource_bytes from public import public from zope.component import getUtility @@ -152,27 +154,28 @@ def initialize_2(debug=False, propagate_logs=None, testing=False): initialize_plugins() # Check for deprecated features in config. config = mailman.config.config - if 'pre_hook' in config.mailman: # pragma: no cover + if config.mailman.pre_hook: # pragma: nocover warnings.warn( - 'The pre_hook configuration value has been replaced by the ' - 'plugins infrastructure.', DeprecationWarning) + _('The pre_hook configuration value has been replaced by the ' + 'plugins infrastructure.'), UserWarning) + call_name(config.mailman.pre_hook) # Run the plugin pre_hooks, if one fails, disable the offending plugin. for name in list(config.plugins.keys()): plugin = config.plugins[name] try: plugin.pre_hook() - except BaseException: # pragma: no cover + except: # pragma: nocover traceback.print_exc() - warnings.warn('Plugin {} failed to run its pre_hook,' - 'it will be disabled and its components' - 'wont be loaded.'.format(name), RuntimeWarning) + warnings.warn(_('Plugin $name failed to run its pre_hook,' + 'it will be disabled and its components' + 'wont be loaded.'), RuntimeWarning) # It failed, push disabling overlay to config. This will stop # components from being loaded. config.push(name + '_error', """\ [plugin.{}] enable: no """.format(name)) - # And forget about it. This will stop running its pot_hook. + # And forget about it. This will stop running its post_hook. del config.plugins[name] # Instantiate the database class, ensure that it's of the right type, and # initialize it. Then stash the object on our configuration object. @@ -199,14 +202,15 @@ def initialize_3(): """ # Run the plugin post_hooks config = mailman.config.config - if 'post_hook' in config.mailman: # pragma: no cover + if config.mailman.post_hook: # pragma: nocover warnings.warn( - 'The post_hook configuration value has been replaced by the ' - 'plugins infrastructure.', DeprecationWarning) + _('The post_hook configuration value has been replaced by the ' + 'plugins infrastructure.'), UserWarning) + call_name(config.mailman.post_hook) for plugin in config.plugins.values(): try: plugin.post_hook() - except: # pragma: no cover + except: # pragma: nocover # A post_hook may fail, here we just hope for the best that the # plugin can work even if it post_hook failed as it's components # are already loaded. |
