本文整理汇总了Python中MaKaC.plugins.base.PluginsHolder.getPlugin方法的典型用法代码示例。如果您正苦于以下问题:Python PluginsHolder.getPlugin方法的具体用法?Python PluginsHolder.getPlugin怎么用?Python PluginsHolder.getPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.plugins.base.PluginsHolder
的用法示例。
在下文中一共展示了PluginsHolder.getPlugin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hasRights
# 需要导入模块: from MaKaC.plugins.base import PluginsHolder [as 别名]
# 或者: from MaKaC.plugins.base.PluginsHolder import getPlugin [as 别名]
def hasRights(request = None, user = None, plugins = []):
""" Returns True if the user is an admin of one of the plugins corresponding to pluginNames
plugins: a list of Plugin objects (e.g. EVO, RecordingRequest) or strings with the plugin name ('EVO', 'RecordingRequest')
or the string 'any' (we will then check if the user is manager of any plugin),
"""
if not PluginsHolder().hasPluginType("Collaboration"):
return False
if user is None:
if request is None:
return False
else:
user = request._getUser()
coll = PluginsHolder().getPluginType('Collaboration')
if plugins == 'any':
plugins = []
for p in CollaborationTools.getCollaborationPluginType().getPluginList():
plugins.append(p.getName())
if plugins:
for plugin in plugins:
if not isinstance(plugin, Plugin):
plugin = coll.getPlugin(plugin)
if user in plugin.getOption('admins').getValue():
return True
return False
示例2: getPluginTPlDir
# 需要导入模块: from MaKaC.plugins.base import PluginsHolder [as 别名]
# 或者: from MaKaC.plugins.base.PluginsHolder import getPlugin [as 别名]
def getPluginTPlDir(self, pTypeName, pluginName, tplName):
pType = PluginsHolder().getPluginType(pTypeName)
if pType == None:
raise Exception(_("The plugin type does not exist"))
if pluginName != None:
plugin = pType.getPlugin(pluginName)
if plugin == None:
raise Exception(_("The plugin does not exist"))
return posixpath.normpath(pkg_resources.resource_filename(plugin.getModule().__name__, 'tpls/{0}'.format(tplName)))
return posixpath.normpath(pkg_resources.resource_filename(pType.getModule().__name__, 'tpls/{0}'.format(tplName)))