+ def __init__(self, baseobj, facility, plugin_type):
+ (whitelist, config) = Store().get_plugins_config(facility)
+ if cherrypy.config.get('debug', False):
+ cherrypy.log('[%s] %s: %s' % (facility, whitelist, config))
+ if whitelist is None:
+ whitelist = []
+ if config is None:
+ config = dict()
+
+ p = Plugins()
+ (pathname, dummy) = os.path.split(inspect.getfile(baseobj))
+ self._plugins = {
+ 'config': config,
+ 'available': p.get_plugins(pathname, plugin_type),
+ 'whitelist': whitelist,
+ 'enabled': []
+ }
+
+ def get_plugin_data(self):
+ return self._plugins
+
+
+class PluginInstaller(object):
+ def __init__(self, baseobj):
+ (pathname, dummy) = os.path.split(inspect.getfile(baseobj))
+ self._pathname = pathname
+
+ def get_plugins(self):
+ p = Plugins()
+ return p.get_plugins(self._pathname, 'Installer')
+
+
+class PluginObject(Log):
+
+ def __init__(self):
+ self.name = None
+ self._config = None
+ self._options = None
+ self._data = Store()
+
+ def get_config_desc(self):
+ """ The configuration description is a dictionary that provides
+ A description of the supported configuration options, as well
+ as the default configuration option values.
+ The key is the option name, the value is an array of 3 elements:
+ - description
+ - option type
+ - default value
+ """
+ return self._options
+
+ def set_config(self, config):
+ self._config = config
+
+ def get_config_value(self, name):
+ value = None
+ if self._config:
+ value = self._config.get(name, None)
+ if not value:
+ if self._options:
+ opt = self._options.get(name, None)
+ if opt:
+ value = opt[2]
+
+ if cherrypy.config.get('debug', False):
+ cherrypy.log('[%s] %s: %s' % (self.name, name, value))
+
+ return value
+
+ def set_config_value(self, option, value):
+ if not self._config:
+ self._config = dict()
+ self._config[option] = value
+
+ def get_plugin_config(self, facility):
+ return self._data.get_plugin_config(facility, self.name)
+
+ def save_plugin_config(self, facility):
+ self._data.save_plugin_config(facility, self.name, self._config)
+
+ def get_data(self, idval=None, name=None, value=None):
+ return self._data.get_data(self.name, idval=idval, name=name,
+ value=value)
+
+ def save_data(self, data):
+ self._data.save_data(self.name, data)
+
+ def new_datum(self, datum):
+ self._data.new_datum(self.name, datum)
+
+ def del_datum(self, idval):
+ self._data.del_datum(self.name, idval)
+
+ def wipe_config_values(self, facility):
+ self._data.wipe_plugin_config(facility, self.name)
+
+ def wipe_data(self):
+ self._data.wipe_data(self.name)