[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/RoleService - Role.py:1.1.2.1 RoleService.py:1.1.2.1 __init__.py:1.1.2.1 role-service.zcml:1.1.2.1

Christian Theune ct@gocept.com
Sat, 25 May 2002 08:52:30 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/RoleService
In directory cvs.zope.org:/tmp/cvs-serv8348/Services/RoleService

Added Files:
      Tag: ctheune-services_move-branch
	Role.py RoleService.py __init__.py role-service.zcml 
Log Message:
Moving RoleService - Part 1
(physical move of the files)


=== Added File Zope3/lib/python/Zope/App/OFS/Services/RoleService/Role.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
# 
##############################################################################
"""

Revision information:
$Id: Role.py,v 1.1.2.1 2002/05/25 12:52:28 ctheune Exp $
"""

from Zope.App.Security.IRole import IRole
from Zope.ComponentArchitecture.IFactory import IFactory
from Zope.App.Security.RegisteredObject import RegisteredObject
from Persistence import Persistent

class Role(RegisteredObject, Persistent):
    __implements__ = IRole
    __class_implements__ = IFactory

    def __init__(self):
        super(Role, self).__init__('', '', '')
    
    def setId(self, id):
        self._id = id
        
    def getInterfaces(self):
        return self.__implements__




=== Added File Zope3/lib/python/Zope/App/OFS/Services/RoleService/RoleService.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
# 
##############################################################################
"""

Revision information:
$Id: RoleService.py,v 1.1.2.1 2002/05/25 12:52:28 ctheune Exp $
"""
from Zope.App.OFS.Container.BTreeContainer import BTreeContainer
from Zope.App.Security.IRoleService import IRoleService
from Zope.App.OFS.Container.IContainer import IContainer
from Zope.App.Security.RoleRegistry import roleRegistry
from Zope.ContextWrapper import ContextMethod
from Zope.ComponentArchitecture import getNextService

class ILocalRoleService(IRoleService, IContainer):
    """TTW manageable role service"""

class RoleService(BTreeContainer):

    __implements__ =  ILocalRoleService

    ############################################################
    # Implementation methods for interface
    # Zope.App.Security.IRoleService.

    def getRole(wrapped_self, rid):
        '''See interface IRoleService'''
        try: return wrapped_self.getObject(rid)
        except KeyError:
            # We failed locally: delegate to a higher-level service.
            sv= getNextService(wrapped_self, 'RoleService')
            if sv: return sv.getRole(rid)
            raise # will be original Key Error
    
    getRole=ContextMethod(getRole)

    def getRoles(wrapped_self):
        '''See interface IRoleService'''
        roles = list(wrapped_self.objectValues())
        roleserv=getNextService(wrapped_self, 'RoleService')
        if roleserv:
            roles.extend(roleserv.getRoles())
        return roles
    
    getRoles=ContextMethod(getRoles)

    #
    ############################################################


=== Added File Zope3/lib/python/Zope/App/OFS/Services/RoleService/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
# 
##############################################################################



=== Added File Zope3/lib/python/Zope/App/OFS/Services/RoleService/role-service.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:security='http://namespaces.zope.org/security'
   xmlns:zmi='http://namespaces.zope.org/zmi'
   xmlns:browser='http://namespaces.zope.org/browser'

   xmlns:service='http://namespaces.zope.org/service'
>

<security:protectClass name=".RoleService.">
   <security:protect interface="Zope.App.Security.IRoleService." 
                     permission_id="Zope.Security" />
   <security:protect interface="Zope.App.OFS.Container.IContainer." 
                     permission_id="Zope.ManageServices" />
</security:protectClass>

<security:protectClass name=".Role.">
   <security:protect interface="Zope.App.Security.IRole." 
                     permission_id="Zope.Security" />
</security:protectClass>


<service:factoryFromClass name="RoleService"
                          class=".RoleService+"
                          permission_id="Zope.ManageServices"
                          title="Role Service" />

<factory component=".Role." />

<include package=".Views" file="views.zcml" />

</zopeConfigure>