[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - IPrincipalPermissionManager.py:1.1.2.1 IPrincipalPermissionMap.py:1.1.2.1 PrincipalPermissionManager.py:1.1.2.1 PrincipalPermissionMap.py:NONE

Barry Warsaw barry@wooz.org
Thu, 13 Dec 2001 15:47:28 -0500


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

Added Files:
      Tag: Zope-3x-branch
	IPrincipalPermissionManager.py IPrincipalPermissionMap.py 
	PrincipalPermissionManager.py 
Removed Files:
      Tag: Zope-3x-branch
	PrincipalPermissionMap.py 
Log Message:
The wiki actually described two interfaces, a query interface and a
management interface for principal/permission maps.  The
IPrincipalPermissionMap is the query-only interface while
IPrincipalPermissionManager (and implementation:
PrincipalPermissionManager) is the write/management interface.

We can remove PrincipalPermissionMap.py because we don't actually
implement the query-only interface separate from the management
interface.


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

"""Management interface for mappings between principals and permissions."""

from Zope.App.Security.IPrincipalPermissionMap import IPrincipalPermissionMap


class IPrincipalPermissionManager(IPrincipalPermissionMap):
    """Management interface for mappings between principals and permissions."""

    def grantPermissionToPrincipal(permission, principal):
        """Bind the permission to the principal.

        permission must be an IPermission
        principal must be an IPrincipal
        """


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

"""Query interface for mappings between principals and permissions."""


from Interface import Interface

class IPrincipalPermissionMap(Interface):
    """Mappings between principals and permissions."""

    def getPrincipalsForPermission(permission):
        """Return the list of principals who have been granted permission.

        permission must be an IPermission.  If no principals have been
        granted this permission, then the empty list is returned.
        """

    def getPermissionsForPrincipal(principal):
        """Return the list of permission granted to this principal.

        principal must be an IPrincipal.  If no permissions have been granted
        to this principal, then the empty list is returned.
        """


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

from Zope.App.Security.IPrincipalPermissionManager \
     import IPrincipalPermissionManager
from Zope.App.Security.SecurityMap import SecurityMap


class PrincipalPermissionManager(SecurityMap):
    """Mappings between principals and permissions."""

    __implements__ = IPrincipalPermissionManager

    """Bind the permission to the principal.

    permission must be an IPermission
    principal must be an IPrincipal
    """
    grantPermissionToPrincipal = SecurityMap.addCell

    """Return the list of principals for the given permission.

    permission must be an IPermission.  If no principals have been granted
    this permission, then the empty list is returned.
    """
    getPrincipalsForPermission = SecurityMap.getColumnsForRow

    """Return the list of permissions for the given principal.

    principal must be an IPrincipal.  If no permissions have been granted
    to this principal, then the empty list is returned.
    """
    getPermissionsForPrincipal = SecurityMap.getRowsForColumn


# Permissions are our rows, and principals are our columns
manager = PrincipalPermissionManager()


=== Removed File Zope3/lib/python/Zope/App/Security/PrincipalPermissionMap.py ===