def unload(*plugins): ''' Unload named plugin(s). ''' observers = PluginImplementations(interfaces.IPluginObserver) for plugin in plugins: if plugin in _PLUGINS: _PLUGINS.remove(plugin) if plugin in _PLUGINS_SERVICE: del _PLUGINS_SERVICE[plugin] else: raise Exception('Cannot unload plugin `%s`' % plugin) service = _get_service(plugin) for observer_plugin in observers: observer_plugin.before_unload(service) service.deactivate() _PLUGINS_CLASS.remove(service.__class__) for observer_plugin in observers: observer_plugin.after_unload(service) plugins_update()
def load(*plugins): ''' Load named plugin(s). ''' output = [] observers = PluginImplementations(interfaces.IPluginObserver) for plugin in plugins: if plugin in _PLUGINS: raise Exception('Plugin `%s` already loaded' % plugin) service = _get_service(plugin) for observer_plugin in observers: observer_plugin.before_load(service) service.activate() for observer_plugin in observers: observer_plugin.after_load(service) _PLUGINS.append(plugin) _PLUGINS_CLASS.append(service.__class__) if isinstance(service, SingletonPlugin): _PLUGINS_SERVICE[plugin] = service output.append(service) plugins_update() # Return extension instance if only one was loaded. If more that one # has been requested then a list of instances is returned in the order # they were asked for. if len(output) == 1: return output[0] return output
def unload(*plugins): """ Unload named plugin(s). :param plugins: List of plugins """ observers = PluginImplementations(IPluginObserver) for plugin in plugins: if plugin in _PLUGINS: _PLUGINS.remove(plugin) if plugin in _PLUGINS_SERVICE: del _PLUGINS_SERVICE[plugin] else: raise Exception("Cannot unload plugin `%s`" % plugin) service = _get_service(plugin) for observer_plugin in observers: observer_plugin.before_unload(service) service.deactivate() _PLUGINS_CLASS.remove(service.__class__) for observer_plugin in observers: observer_plugin.after_unload(service)
def load(plugin): """ Load a single plugin, given a plugin name, class or instance """ observers = PluginImplementations(IPluginObserver) for observer_plugin in observers: observer_plugin.before_load(plugin) service = _get_service(plugin) service.activate() for observer_plugin in observers: observer_plugin.after_load(service) return service
def unload(plugin): """ Unload a single plugin, given a plugin name, class or instance """ _clear_logic_and_auth_caches() observers = PluginImplementations(IPluginObserver) service = _get_service(plugin) for observer_plugin in observers: observer_plugin.before_unload(service) service.deactivate() for observer_plugin in observers: observer_plugin.after_unload(service) return service
def load(*plugins): ''' Load named plugin(s). ''' from ckan.logic import clear_validators_cache, clear_converters_cache output = [] observers = PluginImplementations(interfaces.IPluginObserver) for plugin in plugins: if plugin in _PLUGINS: raise Exception('Plugin `%s` already loaded' % plugin) service = _get_service(plugin) for observer_plugin in observers: observer_plugin.before_load(service) service.activate() for observer_plugin in observers: observer_plugin.after_load(service) if interfaces.IGenshiStreamFilter in service.__interfaces__: log.warn("Plugin '%s' is using deprecated interface " 'IGenshiStreamFilter' % plugin) if interfaces.IValidators in service.__interfaces__: clear_validators_cache() if interfaces.IConverters in service.__interfaces__: clear_converters_cache() _PLUGINS.append(plugin) _PLUGINS_CLASS.append(service.__class__) if isinstance(service, SingletonPlugin): _PLUGINS_SERVICE[plugin] = service output.append(service) plugins_update() # Return extension instance if only one was loaded. If more that one # has been requested then a list of instances is returned in the order # they were asked for. if len(output) == 1: return output[0] return output
def load(plugin): """ Load a single plugin, given a plugin name, class or instance """ _clear_logic_and_auth_caches() observers = PluginImplementations(IPluginObserver) for observer_plugin in observers: observer_plugin.before_load(plugin) service = _get_service(plugin) service.activate() for observer_plugin in observers: observer_plugin.after_load(service) if IGenshiStreamFilter in service.__interfaces__: log.warn( "Plugin '%s' is using deprecated interface IGenshiStreamFilter" % plugin) return service
def implementations(cls): return PluginImplementations(cls)