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:
Lance Stout 2012-03-12 11:06:30 -07:00
parent 57d761b8a2
commit 162e955bd6

View file

@ -89,6 +89,9 @@ def load_plugin(name, module=None):
plugin = getattr(mod, name)
if not hasattr(plugin, '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)
except:
log.exception("Unable to load plugin: %s", name)
@ -132,6 +135,7 @@ class PluginManager(object):
:param dict config: Optional settings dictionary for
configuring plugin behaviour.
"""
top_level = False
if enabled is None:
enabled = set()
@ -156,6 +160,15 @@ class PluginManager(object):
plugin.plugin_init()
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):
"""Enable all registered plugins.