[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - PrincipalRoleMap.py:1.1.2.1
Barry Warsaw
barry@wooz.org
Thu, 13 Dec 2001 12:58:06 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv8682/lib/python/Zope/App/Security
Added Files:
Tag: Zope-3x-branch
PrincipalRoleMap.py
Log Message:
A new map between principals and roles, largely similar to
RolePermissionMap.
=== Added File Zope3/lib/python/Zope/App/Security/PrincipalRoleMap.py ===
# PrincipalRoleMap.py
#
# Copyright (c) 2001 Zope Coporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
"""Mappings between principals roles."""
from Zope.App.Security.SecurityMap import SecurityMap
class PrincipalRoleMap(SecurityMap):
"""Mappings between principals roles."""
"""Bind the role to the principal.
role must be an IRole
principal must be an IPrincipal
"""
grantRoleToPrincipal = SecurityMap.addCell
"""Return the list of principals for the given role.
role must be an IRole. If no principals have been granted
this role, then the empty list is returned.
"""
getPrincipalsForRole = SecurityMap.getColumnsForRow
"""Return the list of roles for the given principal.
principal must be an IPrincipal. If no roles have been granted
to this principal, then the empty list is returned.
"""
getRolesForPrincipal = SecurityMap.getRowsForColumn
# Roles are our rows, and principals are our columns
map = PrincipalRoleMap()