本文整理汇总了Python中AccessControl.Permission.Permission.setRole方法的典型用法代码示例。如果您正苦于以下问题:Python Permission.setRole方法的具体用法?Python Permission.setRole怎么用?Python Permission.setRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AccessControl.Permission.Permission
的用法示例。
在下文中一共展示了Permission.setRole方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: manage_role
# 需要导入模块: from AccessControl.Permission import Permission [as 别名]
# 或者: from AccessControl.Permission.Permission import setRole [as 别名]
def manage_role(self, role_to_manage, permissions=[]):
"""Change the permissions given to the given role.
"""
for p in self.ac_inherited_permissions(1):
name, value = p[:2]
p = Permission(name, value, self)
p.setRole(role_to_manage, name in permissions)
示例2: modifyPermissionMappings
# 需要导入模块: from AccessControl.Permission import Permission [as 别名]
# 或者: from AccessControl.Permission.Permission import setRole [as 别名]
def modifyPermissionMappings(ob, map):
'''
Modifies multiple role to permission mappings.
'''
# This mimics what AccessControl/Role.py does.
# Needless to say, it's crude. :-(
map = map.copy() # Safety.
for perm in ac_inherited_permissions(ob, 1):
name, value = perm[:2]
if map.has_key(name):
for (role, allow) in map[name].items():
p = Permission(name, value, ob)
p.setRole(role, allow) # Will only modify if it should.
del map[name]
if map:
for name, (role, allow) in map.items():
p = Permission(name, (), ob)
p.setRole(role, allow)