From: Patrick Uiterwijk Date: Sat, 5 Sep 2015 00:27:47 +0000 (+0200) Subject: Make it possible to use PluginLoader without store X-Git-Tag: v1.1.0~1 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=commitdiff_plain;h=effa209e386930ad705f255e61c24a5dfb057987;ds=sidebyside Make it possible to use PluginLoader without store In the case of OpenID extensions, a backend store is not needed for the PluginLoader, since the IDP Plugin has its own configuration for enabled extensions. Signed-off-by: Patrick Uiterwijk Reviewed-by: Rob Crittenden --- diff --git a/ipsilon/providers/openid/extensions/common.py b/ipsilon/providers/openid/extensions/common.py index 55809c1..247584c 100644 --- a/ipsilon/providers/openid/extensions/common.py +++ b/ipsilon/providers/openid/extensions/common.py @@ -49,7 +49,7 @@ class LoadExtensions(Log): def __init__(self): self.plugins = PluginLoader(LoadExtensions, - FACILITY, 'OpenidExtension') + FACILITY, 'OpenidExtension', False) self.plugins.get_plugin_data() available = self.plugins.available.keys() diff --git a/ipsilon/providers/openid/store.py b/ipsilon/providers/openid/store.py index 3a45f19..bf2898c 100644 --- a/ipsilon/providers/openid/store.py +++ b/ipsilon/providers/openid/store.py @@ -94,10 +94,6 @@ class OpenIDStore(Store, OpenIDStoreInterface): trans=False) q.create() q._con.close() # pylint: disable=protected-access - q = self._query(self._db, 'openid_extensions', OPTIONS_TABLE, - trans=False) - q.create() - q._con.close() # pylint: disable=protected-access def _upgrade_schema(self, old_version): if old_version == 1: diff --git a/ipsilon/util/plugin.py b/ipsilon/util/plugin.py index 6aecbf6..87ab1ae 100644 --- a/ipsilon/util/plugin.py +++ b/ipsilon/util/plugin.py @@ -58,19 +58,23 @@ class Plugins(object): class PluginLoader(Log): - def __init__(self, baseobj, facility, plugin_type): + def __init__(self, baseobj, facility, plugin_type, uses_store=True): self._pathname, _ = os.path.split(inspect.getfile(baseobj)) self.facility = facility self._plugin_type = plugin_type self.available = dict() self.enabled = list() - self.__data = None + self.__data = False + self.uses_store = uses_store # Defer initialization or instantiating the store will fail at load # time when used with Installer plugins as the cherrypy config context # is created after all Installer plugins are loaded. @property def _data(self): + if not self.uses_store: + raise Exception('Tried to get plugin data while ' + + 'uses_store=False (%s)' % self.facility) if not self.__data: self.__data = AdminStore() return self.__data @@ -92,7 +96,8 @@ class PluginLoader(Log): def get_plugin_data(self): self.available = self.get_plugins() - self.refresh_enabled() + if self.uses_store: + self.refresh_enabled() def save_enabled(self, enabled): if enabled: