def _checkParams(self, params): RHAdminPluginsBase._checkParams(self, params) if self._pluginType is None: raise PluginError(_("pluginType not set")) elif not self._ph.hasPluginType(self._pluginType): raise PluginError( "The plugin type " + self._pluginType + " does not exist, is not visible or is not active")
def _checkParams(self, params): RHAdminBase._checkParams(self, params) self._pluginType = params.get("pluginType", None) self._pluginId = params.get("pluginId", None) self._ph = PluginsHolder() if self._pluginType and not self._ph.hasPluginType(self._pluginType, mustBeActive=False): raise PluginError("The plugin type " + self._pluginType + " does not exist or is not visible") elif self._pluginType and self._pluginId and not self._ph.getPluginType( self._pluginType).hasPlugin(self._pluginId): raise PluginError("The plugin " + self._pluginId + " does not exist")
def getPluginByTypeAndName(cls, type, name): """ Returns a list of strings with the plugin types (e.g. ["epayment", "Collaboration"] """ cls.loadPlugins() if type in cls.pluginList.keys(): modules = cls.pluginList[type] if name in modules: return modules[name] else: raise PluginError("Tried to get a plugin of the type " + type + " with name " + name + " but there is no plugin called " + name) else: raise PluginError("Tried to get a plugin of the type " + type + " but that type doesn't exist")
def _checkParams(self, params): RHAdminBase._checkParams(self, params) self._pluginType = params.get("pluginType", None) #take out white spaces in case there are some if self._pluginType: self._pluginType = self._pluginType.replace(' ', '') self._pluginId = params.get("pluginId", None) #take out white spaces in case there are some if self._pluginId: self._pluginId = self._pluginId.replace(' ', '') self._ph = PluginsHolder() if self._pluginType and not self._ph.hasPluginType(self._pluginType, mustBeActive = False): raise PluginError("The plugin type " + self._pluginType + " does not exist or is not visible") elif self._pluginType and self._pluginId and not self._ph.getPluginType(self._pluginType).hasPlugin(self._pluginId): raise PluginError("The plugin " + self._pluginId + " does not exist")
def _checkProtection(self): if not PluginsHolder().hasPluginType("statistics"): raise PluginError(_("Statistics plugin is not active.")) self._checkSessionUser() RHConferenceModifBase._checkProtection(self)
def _checkParams(self, params): RHAdminPluginsBase._checkParams(self, params) if self._pluginType and not self._ph.hasPluginType(self._pluginType): raise PluginError( "The plugin type " + self._pluginType + " does not exist, is not visible or is not active") self._initialPlugin = params.get('subtab', 0)
def _checkParams(self, params): RHAdminPluginsSaveOptionsBase._checkParams(self, params) if self._pluginId is None: raise PluginError(_("pluginId not set")) self._storeParams(params) self._target = self._ph.getPluginType(self._pluginType).getPlugin(self._pluginId)
def updateAllActions(self, retrievedPluginActions): """ Updates information about the actions. -retrievedPluginActions: a dictionary where keys are strings (the action name) and values are 2-tuples of strings (buttonText, associatedOptionName) """ self.__actions = {} self.clearAssociatedActions() #we get the list of actions of this type if retrievedPluginActions is not None: for index, (name, attributes) in enumerate(retrievedPluginActions): checkedAttributes = PluginBase.checkActionAttributes( name, attributes) associatedOptionName = checkedAttributes["associatedOption"] if associatedOptionName is None: associatedOption = None else: if self.hasOption(associatedOptionName): associatedOption = self.getOption(associatedOptionName) else: raise PluginError("action " + name + " of plugin " + self.getName() + " tried to associate with option " + associatedOptionName + " but this option doesn't exist") newAction = self.addAction(name, checkedAttributes, index) if associatedOption is not None: associatedOption.addAssociatedAction(self.getAction(name)) if newAction.isExecuteOnLoad(): newAction.call()
def getPluginsByType(cls, type): """ Given a type (e.g. "Collaboration"), and a name (e.g. "EVO") a module object corresponding to that plugin is returned """ cls.loadPlugins() if type in cls.pluginList.keys(): return cls.pluginList[type].values() else: raise PluginError("Tried to reload plugins of type " + str(type) + " but that type doesn't exist")
def setValue(self, value): if isinstance(self.__type, type): self.__value = self.__type(value) elif self.__type in PluginOption._extraTypes: self.__value = PluginOption._extraTypes[self.__type](value) else: raise PluginError( """Tried to set value of option %s with type %s but this type is not recognized""" % (self.__name, self.__type))
def _checkProtection(self): if not PluginsHolder().hasPluginType("Collaboration"): raise PluginError("Collaboration plugin system is not active") hasRights = RCCollaborationAdmin.hasRights(self, None) or \ RCCollaborationPluginAdmin.hasRights(self, None, self._tabPlugins) or \ RCVideoServicesManager.hasRights(self, self._tabPlugins) if not hasRights: RHConferenceModifBase._checkProtection(self)
def _checkProtection(self): if not PluginsHolder().hasPluginType("Collaboration"): raise PluginError("Collaboration plugin system is not active") if not RCCollaborationAdmin.hasRights( self, None ) and not RCCollaborationPluginAdmin.hasRights( self, plugins="any" ): #RCCollaborationPluginAdmin.hasRights(self, None, self._tabPlugins): RHAdminBase._checkProtection(self)
def reloadPluginType(self, type): """ Reloads plugins of a given type and updates their information """ Plugins.reloadPluginsByType(type) if self.hasPluginType(type, mustBeActive=False): self.getPluginType(type).updateInfo() else: raise PluginError( "Error while trying to reload plugins of the type: " + type + ". Plugins of the type " + type + "do not exist")
def reloadPluginsByType(cls, type): """ Forces to reload plugins if they are already in memory, but only those of a given type (e.g. "epayment", "Collaboration"). """ cls.loadPlugins() if not type in cls.pluginList.keys(): raise PluginError("Tried to reload plugins of type " + str(type) + " but that type doesn't exist") cls.pluginList[type] = {} cls._pluginsLoaded = False #TODO: have different flags for different types of plugins... but if memory isn't consistently shared between requests, it's not possible... cls.changePath() cls.findPluginsByType(type) cls._pluginsLoaded = True for plugin in cls.pluginList[type].values(): plugin.initModule(plugin) cls.restorePath()
def checkOptionAttributes(cls, name, attributes): """ Utility method that takes a dictionary with option attributes. It verifies some attributes and sets default values for others if they don't exist. """ if attributes.has_key("description"): description = attributes["description"] else: raise PluginError('Option ' + str(name) + ' does not have a "description" attribute') if attributes.has_key("type"): optionType = attributes["type"] else: raise PluginError('Option ' + str(name) + ' does not have a "type" attribute') return { "description": description, "type": optionType, "defaultValue": attributes.get("defaultValue", None), "editable": attributes.get("editable", True), "visible": attributes.get("visible", True), "mustReload": attributes.get("mustReload", False) }
def getPluginByTypeAndId(cls, ptypeId, pid): """ Returns the module object of a plugin given the names of the plugin and its type """ if not ptypeId in cls._ptypesLoaded: cls.reloadPluginType(ptypeId) modulesDict = cls._pmodules[ptypeId] if pid in modulesDict: return modulesDict[pid] else: raise PluginError("Tried to get a plugin of the type %s with id %s " "but there is no such plugin" % (ptypeId, pid))
def checkActionAttributes(cls, name, attributes): """ Utility method that takes a dictionary with actions attributes. It verifies some attributes and sets default values for others if they don't exist. """ if (not attributes.has_key("visible") or (attributes.has_key("visible") and attributes["visible"])) and not attributes.has_key("buttonText"): raise PluginError( 'Action ' + str(name) + ' does not have a "buttonText" attribute, but it is visible') return { "buttonText": attributes.get("buttonText", None), "associatedOption": attributes.get("associatedOption", None), "visible": attributes.get("visible", True), "executeOnLoad": attributes.get("executeOnLoad", False), "triggeredBy": attributes.get("triggeredBy", []) }
def _checkProtection(self): if not PluginsHolder().hasPluginType("Collaboration"): raise PluginError("Collaboration plugin system is not active") if not RCVideoServicesManager.hasRights(self): RHConferenceModifBase._checkProtection(self)
def call(self): """ To be implemented by inheriting classes """ raise PluginError("Action of class " + str(self.__class__.__name__) + " has not implemented the method call()")
def _checkProtection(self): if not PluginsHolder().hasPluginType("search"): raise PluginError(_("Search plugin is not active."))
def _checkParams(self, params): RHAdminPluginsBase._checkParams(self, params) if self._pluginType is None: raise PluginError(_("pluginType not set")) if self._pluginId is None: raise PluginError(_("pluginId not set"))