From 162e955bd6200e4c9ca22e677adec3c30aec173e Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 12 Mar 2012 11:06:30 -0700 Subject: [PATCH] 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. --- sleekxmpp/plugins/base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sleekxmpp/plugins/base.py b/sleekxmpp/plugins/base.py index d1fb26a0..ec5ed10b 100644 --- a/sleekxmpp/plugins/base.py +++ b/sleekxmpp/plugins/base.py @@ -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.