import CryptoBoxPlugin class plugin_manager(CryptoBoxPlugin.CryptoBoxPlugin): pluginCapabilities = [ "system" ] requestAuth = True rank = 90 def doAction(self, store=None, **args): import re if store: for key in args.keys(): if key.endswith("_listed"): if not re.search(u'\W',key): self.__setConfig(key[:-7], args) else: self.cbox.log.info("plugin_manager: invalid plugin name (%s)" % str(key[:-7])) try: self.cbox.prefs.pluginConf.write() except IOError: self.cbox.log.warn("failed to write plugin configuration") return "plugin_list" def getStatus(self): return "no status" def __setConfig(self, name, args): setting = {} setting["enabled"] = False try: if args[name + "_enabled"]: setting["enabled"] = True except KeyError: pass setting["rank"] = "80" try: r = int(args[name + "_rank"]) if r>=0 and r<=100: setting["rank"] = r except KeyError, ValueError: pass setting["requestAuth"] = False try: if args[name + "_auth"]: setting["requestAuth"] = True except KeyError, ValueError: pass self.cbox.prefs.pluginConf[name] = setting