diff options
author | Tom Nichols <tmnichols@gmail.com> | 2010-06-08 10:40:15 -0400 |
---|---|---|
committer | Tom Nichols <tmnichols@gmail.com> | 2010-06-08 10:40:15 -0400 |
commit | 4fccd77685b73f7cf750fb761ca2714a88caec91 (patch) | |
tree | bf856b56b5569de82d2807487130321039b75b4a /sleekxmpp/basexmpp.py | |
parent | 77bff9cce7deff133017c3aa2c36ff121adfd544 (diff) | |
parent | 34dc236126d272a16df0915b010dca0e2e38f0d4 (diff) | |
download | slixmpp-4fccd77685b73f7cf750fb761ca2714a88caec91.tar.gz slixmpp-4fccd77685b73f7cf750fb761ca2714a88caec91.tar.bz2 slixmpp-4fccd77685b73f7cf750fb761ca2714a88caec91.tar.xz slixmpp-4fccd77685b73f7cf750fb761ca2714a88caec91.zip |
Merge branch 'hacks' of git@github.com:tomstrummer/SleekXMPP into hacks
Diffstat (limited to 'sleekxmpp/basexmpp.py')
-rw-r--r-- | sleekxmpp/basexmpp.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py index a916fe86..b78c255c 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,21 +91,27 @@ 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)) - # init the plugin class - self.plugin[plugin] = getattr(getattr(plugins, plugin), plugin)(self, pconfig) # eek - # all of this for a nice debug? sure. - xep = '' - if hasattr(self.plugin[plugin], 'xep'): - xep = "(XEP-%s) " % self.plugin[plugin].xep - logging.debug("Loaded Plugin %s%s" % (xep, self.plugin[plugin].description)) - + try: + if pluginModule: + module = __import__(pluginModule, globals(), locals(), [plugin]) + else: + module = __import__("%s.%s" % (globals()['plugins'].__name__, plugin), globals(), locals(), [plugin]) + # init the plugin class + self.plugin[plugin] = getattr(module, plugin)(self, pconfig) # eek + # all of this for a nice debug? sure. + xep = '' + if hasattr(self.plugin[plugin], 'xep'): + xep = "(XEP-%s) " % self.plugin[plugin].xep + logging.debug("Loaded Plugin %s%s" % (xep, self.plugin[plugin].description)) + except: + logging.error("Unable to load plugin: %s" %(plugin) ) + def register_plugins(self): """Initiates all plugins in the plugins/__init__.__all__""" if self.plugin_whitelist: |