summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/base.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-03-12 11:06:30 -0700
committerLance Stout <lancestout@gmail.com>2012-03-12 19:32:20 -0700
commit162e955bd6200e4c9ca22e677adec3c30aec173e (patch)
treeb5b9fdc38b4bd34c080e65eec60ad793dd9f78ae /sleekxmpp/plugins/base.py
parent57d761b8a2cb01d061a37ef1d9d5fb992a9e1dcf (diff)
downloadslixmpp-162e955bd6200e4c9ca22e677adec3c30aec173e.tar.gz
slixmpp-162e955bd6200e4c9ca22e677adec3c30aec173e.tar.bz2
slixmpp-162e955bd6200e4c9ca22e677adec3c30aec173e.tar.xz
slixmpp-162e955bd6200e4c9ca22e677adec3c30aec173e.zip
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.
Diffstat (limited to 'sleekxmpp/plugins/base.py')
-rw-r--r--sleekxmpp/plugins/base.py13
1 files changed, 13 insertions, 0 deletions
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.