[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - PrincipalRoleManager.py:1.1.2.1

Barry Warsaw barry@wooz.org
Thu, 13 Dec 2001 16:03:27 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv935

Added Files:
      Tag: Zope-3x-branch
	PrincipalRoleManager.py 
Log Message:
Management implementation for mappings between principals and roles.


=== Added File Zope3/lib/python/Zope/App/Security/PrincipalRoleManager.py ===
# PrincipalRoleManager.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 and roles."""

from Zope.App.Security.SecurityMap import SecurityMap


class PrincipalRoleManager(SecurityMap):
    """Mappings between principals roles."""

    """Assign the role to the principal.

    role must be an IRole
    principal must be an IPrincipal
    """
    assignRoleToPrincipal = SecurityMap.addCell

    """Return the list of principals assigned the given role.

    role must be an IRole.  If no principals have been assigned
    this role, then the empty list is returned.
    """
    getPrincipalsForRole = SecurityMap.getColumnsForRow

    """Return the list of roles assigned to the given principal.

    principal must be an IPrincipal.  If no roles have been assigned
    to this principal, then the empty list is returned.
    """
    getRolesForPrincipal = SecurityMap.getRowsForColumn


# Roles are our rows, and principals are our columns
manager = PrincipalRoleManager()