Enable using post_init() to resolve circular dependencies.
We really shouldn't have any. However, we may later introduce one with XEP-0030 and XEP-0059.
This commit is contained in:
parent
57d761b8a2
commit
162e955bd6
@ -89,6 +89,9 @@ def load_plugin(name, module=None):
|
|||||||
plugin = getattr(mod, name)
|
plugin = getattr(mod, name)
|
||||||
if not hasattr(plugin, 'name'):
|
if not hasattr(plugin, 'name'):
|
||||||
plugin.name = name
|
plugin.name = name
|
||||||
|
# Mark the plugin as an older style plugin so
|
||||||
|
# we can work around dependency issues.
|
||||||
|
plugin.old_style = True
|
||||||
register_plugin(plugin, name)
|
register_plugin(plugin, name)
|
||||||
except:
|
except:
|
||||||
log.exception("Unable to load plugin: %s", name)
|
log.exception("Unable to load plugin: %s", name)
|
||||||
@ -132,6 +135,7 @@ class PluginManager(object):
|
|||||||
:param dict config: Optional settings dictionary for
|
:param dict config: Optional settings dictionary for
|
||||||
configuring plugin behaviour.
|
configuring plugin behaviour.
|
||||||
"""
|
"""
|
||||||
|
top_level = False
|
||||||
if enabled is None:
|
if enabled is None:
|
||||||
enabled = set()
|
enabled = set()
|
||||||
|
|
||||||
@ -156,6 +160,15 @@ class PluginManager(object):
|
|||||||
plugin.plugin_init()
|
plugin.plugin_init()
|
||||||
log.debug("Loaded Plugin: %s", plugin.description)
|
log.debug("Loaded Plugin: %s", plugin.description)
|
||||||
|
|
||||||
|
if top_level:
|
||||||
|
for name in enabled:
|
||||||
|
if hasattr(self.plugins[name], 'old_style'):
|
||||||
|
# Older style plugins require post_init()
|
||||||
|
# to run just before stream processing begins,
|
||||||
|
# so we don't call it here.
|
||||||
|
pass
|
||||||
|
self.plugins[name].post_init()
|
||||||
|
|
||||||
def enable_all(self, names=None, config=None):
|
def enable_all(self, names=None, config=None):
|
||||||
"""Enable all registered plugins.
|
"""Enable all registered plugins.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user