本文整理汇总了Python中ckan.authz.Authorizer.all方法的典型用法代码示例。如果您正苦于以下问题:Python Authorizer.all方法的具体用法?Python Authorizer.all怎么用?Python Authorizer.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ckan.authz.Authorizer
的用法示例。
在下文中一共展示了Authorizer.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: group_list_authz
# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import all [as 别名]
def group_list_authz(context, data_dict):
'''
Returns a list of groups which the user is allowed to edit
If 'available_only' is specified, the existing groups in the package are
removed.
'''
model = context['model']
user = context['user']
available_only = data_dict.get('available_only',False)
check_access('group_list_authz',context, data_dict)
query = Authorizer().authorized_query(user, model.Group, model.Action.EDIT)
groups = set(query.all())
if available_only:
package = context.get('package')
if package:
groups = groups - set(package.get_groups())
return [{'id':group.id,'name':group.name} for group in groups]
示例2: group_list_authz
# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import all [as 别名]
def group_list_authz(context, data_dict):
"""
Returns a list of groups which the user is allowed to edit
If 'available_only' is specified, the existing groups in the package are
removed.
"""
model = context["model"]
user = context["user"]
available_only = data_dict.get("available_only", False)
check_access("group_list_authz", context, data_dict)
query = Authorizer().authorized_query(user, model.Group, model.Action.EDIT)
groups = set(query.all())
if available_only:
package = context.get("package")
if package:
groups = groups - set(package.groups)
return [{"id": group.id, "name": group.name} for group in groups]