Resolve plugin dependency chains with XEP-0115.

The post_init() system can only reliably handle a single layer
of dependencies between plugins, but PEP plugins with XEP-0115
exceed that limit and plugins can be post_init'ed out of order. To
resolve this, we will special case XEP-0115 to be post_init'ed
first until the new plugin system with dependency tracking is
stable.
This commit is contained in:
Lance Stout
2012-03-10 12:48:35 -08:00
parent 7f71ac7e0a
commit 91155444c0
4 changed files with 17 additions and 15 deletions

View File

@@ -185,6 +185,16 @@ class BaseXMPP(XMLStream):
- The send queue processor
- The scheduler
"""
# The current post_init() process can only resolve a single
# layer of inter-plugin dependencies. However, XEP-0115 and
# plugins which depend on it exceeds this limit and can cause
# failures if plugins are post_inited out of order, so we must
# manually process XEP-0115 first.
if 'xep_0115' in self.plugin:
if not self.plugin['xep_0115'].post_inited:
self.plugin['xep_0115'].post_init()
for name in self.plugin:
if not self.plugin[name].post_inited:
self.plugin[name].post_init()
@@ -257,10 +267,6 @@ class BaseXMPP(XMLStream):
else:
raise NameError("Plugin %s not in plugins.__all__." % plugin)
# Resolve plugin inter-dependencies.
for plugin in self.plugin:
self.plugin[plugin].post_init()
def __getitem__(self, key):
"""Return a plugin given its name, if it has been registered."""
if key in self.plugin: