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


Python IPrincipalRoleMap.getRolesForPrincipal方法代码示例

本文整理汇总了Python中zope.securitypolicy.interfaces.IPrincipalRoleMap.getRolesForPrincipal方法的典型用法代码示例。如果您正苦于以下问题:Python IPrincipalRoleMap.getRolesForPrincipal方法的具体用法?Python IPrincipalRoleMap.getRolesForPrincipal怎么用?Python IPrincipalRoleMap.getRolesForPrincipal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zope.securitypolicy.interfaces.IPrincipalRoleMap的用法示例。


在下文中一共展示了IPrincipalRoleMap.getRolesForPrincipal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cached_principal_roles

# 需要导入模块: from zope.securitypolicy.interfaces import IPrincipalRoleMap [as 别名]
# 或者: from zope.securitypolicy.interfaces.IPrincipalRoleMap import getRolesForPrincipal [as 别名]
    def cached_principal_roles(self, parent, principal):
        cache = self.cache(parent)
        try:
            cache_principal_roles = cache.principal_roles
        except AttributeError:
            cache_principal_roles = cache.principal_roles = {}
        try:
            return cache_principal_roles[principal]
        except KeyError:
            pass

        if parent is None:
            roles = dict(
                [(role, SettingAsBoolean[setting])
                 for (role, setting) in globalRolesForPrincipal(principal)])
            roles['zope.Anonymous'] = True  # Everybody has Anonymous
            cache_principal_roles[principal] = roles
            return roles

        roles = self.cached_principal_roles(
            removeSecurityProxy(getattr(parent, '__parent__', None)),
            principal)

        prinrole = IPrincipalRoleMap(parent, None)
        if prinrole:
            roles = roles.copy()
            for role, setting in prinrole.getRolesForPrincipal(principal):
                roles[role] = SettingAsBoolean[setting]

        cache_principal_roles[principal] = roles
        return roles
开发者ID:jean,项目名称:zope.securitypolicy,代码行数:33,代码来源:zopepolicy.py

示例2: cached_principal_roles

# 需要导入模块: from zope.securitypolicy.interfaces import IPrincipalRoleMap [as 别名]
# 或者: from zope.securitypolicy.interfaces.IPrincipalRoleMap import getRolesForPrincipal [as 别名]
 def cached_principal_roles(self, parent, principal):
     cache = self.cache(parent)
     try:
         cache_principal_roles = cache.principal_roles
     except AttributeError:
         cache_principal_roles = cache.principal_roles = {}
     try:
         return cache_principal_roles[principal]
     except KeyError:
         pass
     
     if parent is None:
         roles = dict(
             [(role, zopepolicy.SettingAsBoolean[setting])
              for (role, setting) in
              zopepolicy.globalRolesForPrincipal(principal)])
         roles['zope.Anonymous'] = True  # Everybody has Anonymous
         cache_principal_roles[principal] = roles
         return roles
     
     roles = self.cached_principal_roles(
         removeSecurityProxy(getattr(parent, '__parent__', None)),
         principal)
     
     prinrole = IPrincipalRoleMap(parent, None)
     if prinrole:
         roles = roles.copy()
         for role, setting in prinrole.getRolesForPrincipal(principal):
             roles[role] = zopepolicy.SettingAsBoolean[setting]
     # The lines below include the group that a document has been assigned
     # to into the lookup hierarchy.
     group_assignments = getattr(parent, "sa_group_assignments", [])
     for group_assignment in group_assignments:
         group = group_assignment.principal
         #!+GROUP_ASSIGNMENT.GROUP assert isinstance(group, domain.Group), group
         assigned_group_prinrole = IPrincipalRoleMap(group, None)
         if assigned_group_prinrole:
             roles = roles.copy()
             role_settings = assigned_group_prinrole.getRolesForPrincipal(
                 principal)
             for role, setting in role_settings:
                 roles[role] = zopepolicy.SettingAsBoolean[setting]
     cache_principal_roles[principal] = roles
     return roles
开发者ID:kohsah,项目名称:bungeni-portal,代码行数:46,代码来源:__init__.py

示例3: getAllRoles

# 需要导入模块: from zope.securitypolicy.interfaces import IPrincipalRoleMap [as 别名]
# 或者: from zope.securitypolicy.interfaces.IPrincipalRoleMap import getRolesForPrincipal [as 别名]
 def getAllRoles(self):
     hfr = IPrincipalRoleMap(self.homefolder)
     masteruser = False
     ret = []
     for rolesetting in hfr.getRolesForPrincipal(self.principal.id):
         role, setting = rolesetting
         if 'uvc.Editor' == role and setting is Allow:
             masteruser = True
             ret.append('ENMS')
     for name, productfolder in self.homefolder.items():
         if not name.startswith('__'):
             if masteruser:
                 ret.append(name)
             else:
                 prm = IPrincipalRoleMap(productfolder)
                 for rolesetting in prm.getRolesForPrincipal(self.principal.id):
                     role, setting = rolesetting
                     if 'uvc.Editor' == role and setting is Allow:
                         ret.append(name)
     return ret
开发者ID:novareto,项目名称:uvcsite,代码行数:22,代码来源:roles.py

示例4: roles

# 需要导入模块: from zope.securitypolicy.interfaces import IPrincipalRoleMap [as 别名]
# 或者: from zope.securitypolicy.interfaces.IPrincipalRoleMap import getRolesForPrincipal [as 别名]
 def roles(self):
     prmap = IPrincipalRoleMap(self.context)
     return [ids for ids, setting in prmap.getRolesForPrincipal(self.principal_id)]
开发者ID:ilshad,项目名称:tackle,代码行数:5,代码来源:security.py


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