mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-12-22 11:09:11 +00:00
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.
This commit is contained in:
parent
59b8406573
commit
c0457cf5d0
2 changed files with 11 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@
|
||||||
build/
|
build/
|
||||||
*.swp
|
*.swp
|
||||||
.pydevproject
|
.pydevproject
|
||||||
|
.settings
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""
|
"""
|
||||||
SleekXMPP: The Sleek XMPP Library
|
SleekXMPP: The Sleek XMPP Library
|
||||||
Copyright (C) 2010 Nathanael C. Fritz
|
Copyright (C) 2010 Nathanael C. Fritz
|
||||||
This file is part of SleekXMPP.
|
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
|
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()
|
if not self.plugin[idx].post_inited: self.plugin[idx].post_init()
|
||||||
return super(basexmpp, self).process(*args, **kwargs)
|
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
|
"""Register a plugin not in plugins.__init__.__all__ but in the plugins
|
||||||
directory."""
|
directory."""
|
||||||
# discover relative "path" to the plugins module from the main app, and import it.
|
# discover relative "path" to the plugins module from the main app, and import it.
|
||||||
# TODO:
|
# TODO:
|
||||||
# gross, this probably isn't necessary anymore, especially for an installed module
|
# 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
|
# 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.
|
# all of this for a nice debug? sure.
|
||||||
xep = ''
|
xep = ''
|
||||||
if hasattr(self.plugin[plugin], 'xep'):
|
if hasattr(self.plugin[plugin], 'xep'):
|
||||||
|
|
Loading…
Reference in a new issue