当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.roles_in_context方法代码示例

本文整理汇总了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() 
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:11,代码来源:user.py

示例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) 
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:19,代码来源:user.py


注:本文中的penelope.core.models.DBSession.roles_in_context方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。