[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/RoleService - RoleService.py:1.1.2.3 role-service.zcml:1.1.2.3

Gary Poster garyposter@earthlink.net
Mon, 22 Apr 2002 15:03:51 -0400


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

Modified Files:
      Tag: Zope-3x-branch
	RoleService.py role-service.zcml 
Log Message:
1. As per ZopeTop discussion, moved Addable out of ZMI into the Services folder, and turned it into a true service (this involved a lot of small changes, particularly in the folders and a number of tests) and gave it some hooks
2. used SteveA's ContextWrapper.ContextMethod to make the ServiceManager and Services placefully look up to parent placeful equivalents
3. Made Event into a more standard service, and gave it some hooks
4. Built the beginning of a placeful EventService (will need tests, and views, and EventChannels, and more meat; just wanted to check this in for now)
5. made it so you can't add an item to a folder with a blank string id, and updated the folder interface
6. some typos fixed here and there
7. a few more tests here and there

I'm checking this in then checking it out again to check my work; also tagged previous version as gary-service_update.



=== Zope3/lib/python/Zope/App/OFS/RoleService/RoleService.py 1.1.2.2 => 1.1.2.3 ===
 $Id$
 """
-from Persistence import Persistent
 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 IRoleService(IRoleService, IContainer):
+class ILocalRoleService(IRoleService, IContainer):
     """TTW manageable role service"""
 
 class RoleService(BTreeContainer):
 
-    __implements__ =  IRoleService
+    __implements__ =  ILocalRoleService
 
     ############################################################
     # Implementation methods for interface
     # Zope.App.Security.IRoleService.
 
-    def getRole(self, rid):
+    def getRole(wrapped_self, rid):
         '''See interface IRoleService'''
-        try: return self.getObject(rid)
+        try: return wrapped_self.getObject(rid)
         except KeyError:
-            # We failed locally, delegate tyo a higher-level service.
-
-            # XXX We really needs context binding to make this work right.
-            # For now, we'll just delagate to the global registry.
-            return roleRegistry.getRole(rid)
-            
+            # 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(self):
+    def getRoles(wrapped_self):
         '''See interface IRoleService'''
-
-        # XXX We really needs context binding to make this work right.
-        # For now, we'll just delagate to the global registry.
-        roles = list(roleRegistry.getRoles())
-        roles.extend(self.objectValues())
+        roles = list(wrapped_self.objectValues())
+        roleserv=getNextService(wrapped_self, 'RoleService')
+        if roleserv:
+            roles.extend(roleserv.getRoles())
         return roles
     
+    getRoles=ContextMethod(getRoles)
+
     #
     ############################################################


=== Zope3/lib/python/Zope/App/OFS/RoleService/role-service.zcml 1.1.2.2 => 1.1.2.3 ===
 >
 
-<security:protectClass name=".RoleService.">
+<security:protectClass name=".RoleService+">
    <security:instances permission_id="Zope.Public" />
    <security:protect interface="Zope.App.Security.IRoleService." 
                      permission_id="Zope.Security" />
@@ -23,7 +23,7 @@
 
 
 <service:factoryFromClass name="RoleService"
-                          class=".RoleService."
+                          class=".RoleService+"
                           permission_id="Zope.ManageServices"
                           title="Role Service" />