本文整理汇总了Python中penelope.core.models.DBSession.roles_in_context方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.roles_in_context方法的具体用法?Python DBSession.roles_in_context怎么用?Python DBSession.roles_in_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类penelope.core.models.DBSession
的用法示例。
在下文中一共展示了DBSession.roles_in_context方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_permission_groups
# 需要导入模块: from penelope.core.models import DBSession [as 别名]
# 或者: from penelope.core.models.DBSession import roles_in_context [as 别名]
def get_permission_groups(self, username):
# TODO: work only for por/trac on the same wsgi stack
project_id = self.env.config.get('por-dashboard', 'project-id')
if project_id:
project = DBSession().query(Project).get(project_id)
user = DBSession().query(User).filter_by(email=username).first()
if user:
return list(user.roles_in_context(context=project))
return list()
示例2: get_user_permissions
# 需要导入模块: from penelope.core.models import DBSession [as 别名]
# 或者: from penelope.core.models.DBSession import roles_in_context [as 别名]
def get_user_permissions(self, username):
"""Return all permissions for the user with the specified name.
The permissions are returned as a dictionary where the key is the name
of the permission, and the value is either `True` for granted
permissions or `False` for explicitly denied permissions."""
# TODO: work only for por/trac on the same wsgi stack
actions = set(super(PorPermissionStore, self).get_user_permissions(username))
project_id = self.env.config.get('por-dashboard', 'project-id')
if project_id:
project = DBSession().query(Project).get(project_id)
user = DBSession().query(User).filter_by(email=username).first()
if user:
for role in user.roles_in_context(context=project):
actions.update(set(super(PorPermissionStore, self).get_user_permissions(role)))
return list(actions)