summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorBrian Beggs <macdiesel@gmail.com>2010-06-02 20:28:49 +0800
committerThom Nichols <tmnichols@gmail.com>2010-06-03 01:29:49 +0800
commit184f7cb8a4d2835c317eca7db129fb06d92a336a (patch)
tree4b3d001123b8bbb1bbf7f6aab8d6b92339b7c26d /sleekxmpp
parente1aa4d0b93f09b92506af8bb21e87c367905e194 (diff)
downloadslixmpp-184f7cb8a4d2835c317eca7db129fb06d92a336a.tar.gz
slixmpp-184f7cb8a4d2835c317eca7db129fb06d92a336a.tar.bz2
slixmpp-184f7cb8a4d2835c317eca7db129fb06d92a336a.tar.xz
slixmpp-184f7cb8a4d2835c317eca7db129fb06d92a336a.zip
moddified plugin loading so plugins located outside of the plugins directory in sleek may be loaded. Added optional argument pluginModule that is a string that represents the module the desired plugin should be loaded from.
An exception on plugin loading now also will not cause the program to exit. The exception is caught and loading of other plugins contains.
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/basexmpp.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index a916fe86..5f330176 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -1,9 +1,9 @@
"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2010 Nathanael C. Fritz
- This file is part of SleekXMPP.
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2010 Nathanael C. Fritz
+ This file is part of SleekXMPP.
- See the file license.txt for copying permission.
+ See the file license.txt for copying permission.
"""
from __future__ import with_statement, unicode_literals
@@ -91,15 +91,18 @@ class basexmpp(object):
if not self.plugin[idx].post_inited: self.plugin[idx].post_init()
return super(basexmpp, self).process(*args, **kwargs)
- def registerPlugin(self, plugin, pconfig = {}):
+ def registerPlugin(self, plugin, pconfig = {}, pluginModule = None):
"""Register a plugin not in plugins.__init__.__all__ but in the plugins
directory."""
# discover relative "path" to the plugins module from the main app, and import it.
# TODO:
# gross, this probably isn't necessary anymore, especially for an installed module
- __import__("%s.%s" % (globals()['plugins'].__name__, plugin))
+ if pluginModule:
+ module = __import__("%s.%s" % (pluginModule, plugin), globals(), locals(), [plugin])
+ else:
+ module = __import__("%s.%s" % (globals()['plugins'].__name__, plugin), globals(), locals(), [plugin])
# init the plugin class
- self.plugin[plugin] = getattr(getattr(plugins, plugin), plugin)(self, pconfig) # eek
+ self.plugin[plugin] = getattr(module, plugin)(self, pconfig) # eek
# all of this for a nice debug? sure.
xep = ''
if hasattr(self.plugin[plugin], 'xep'):