[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager - hooks.py:1.1.4.2 service-manager.zcml:1.1.4.3

Jim Fulton jim@zope.com
Fri, 7 Jun 2002 10:41:45 -0400


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

Modified Files:
      Tag: Zope-3x-branch
	hooks.py service-manager.zcml 
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals): 
- RenameAllowToRequire

- GroupClassRelatedDirectivesInClassDirective

- ViewInterfaceAndSimplification

- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes

- TwoArgumentViewConstructors

- ImplementsInZCML

- SimpleViewCreationInZCML

- RemoveGetView

- ReplaceProtectWithAllow

- ViewMethodsAsViews

- MergeProtectionAndComponentDefinitions

There were also various security fixes resulting of better integration
of security with components.


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/hooks.py 1.1.4.1 => 1.1.4.2 ===
 from Zope.ComponentArchitecture.GlobalServiceManager import serviceManager
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
+from Zope.Security.Proxy import trustedRemoveSecurityProxy
     
 def getServiceManager_hook(context):
     """
@@ -30,25 +31,38 @@
     service manager if no service manager found within context
     """
     while context is not None:
-        clean_context=removeAllProxies(context)
+        clean_context = removeAllProxies(context)
+
         # if the context is actually a service or service manager...
         if IServiceManager.isImplementedBy(clean_context):
-            return context
-        if IServiceManagerContainer.isImplementedBy(
-            clean_context) and clean_context.hasServiceManager():
-            return ContextWrapper(context.getServiceManager(), context, name="Services;etc")
+            return trustedRemoveSecurityProxy(context)
+        
+        if (IServiceManagerContainer.isImplementedBy(clean_context) and
+            clean_context.hasServiceManager()
+            ):
+            return ContextWrapper(
+                trustedRemoveSecurityProxy(context.getServiceManager()),
+                context,
+                name="etc::Services",
+                )
+                                  
         context = getWrapperContainer(context)
+
     return serviceManager
 
 def getNextServiceManager_hook(context):
     """if the context is a service manager or a placeful service, tries
     to return the next highest service manager"""
-    context=getServiceManager(context)
+
+    context = getServiceManager(context)
     if context is serviceManager: return None
+
     context=getWrapperContainer(context)
-    while context and not \
-          IServiceManagerContainer.isImplementedBy(removeAllProxies(context)):
+    while (context and not 
+           IServiceManagerContainer.isImplementedBy(removeAllProxies(context))
+           ):
         context=getWrapperContainer(context) # we should be
+
     # able to rely on the first step getting us a
     # ServiceManagerContainer
     context=getWrapperContainer(context)


=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/service-manager.zcml 1.1.4.2 => 1.1.4.3 ===
    xmlns:browser='http://namespaces.zope.org/browser'
 >
+  <content class=".ServiceManager.">
+    <security:require
+        permission="Zope.Public"
+        interface="Zope.App.OFS.Container.IContainer.IReadContainer" />
+    <security:require
+        permission="Zope.ManageServices"
+        interface="Zope.App.OFS.Container.IContainer.IWriteContainer" />
+    <security:require
+        permission="Zope.ManageServices"
+        interface="Zope.App.OFS.Services.ServiceManager.IServiceManager." />
+  </content>
 
-<security:protectClass class="Zope.App.OFS.Services.ServiceManager+"
-                       permission_id="Zope.Public">
-   
-    <security:protect
-        interface="Zope.App.OFS.Container.IContainer.IReadContainer"
-        permission_id="Zope.Public" />
-    <security:protect
-        interface="Zope.App.OFS.Container.IContainer.IWriteContainer"
-        permission_id="Zope.ManageServices" />
-   
-   <security:protect
-        interface="Zope.App.OFS.Services.ServiceManager.IServiceManager+"
-        permission_id="Zope.ManageServices" />
-    
-   </security:protectClass>
+  <include package="Zope.App.OFS.Services.ServiceManager.Views" 
+           file="views.zcml" />
 
-<include package="Zope.App.OFS.Services.ServiceManager.Views" 
-    file="views.zcml" />
-
-<hook module="Zope.ComponentArchitecture" name="getServiceManager"
-   implementation=".hooks.getServiceManager_hook" />
-<hook module="Zope.ComponentArchitecture"
-    name="getNextServiceManager"
-    implementation=".hooks.getNextServiceManager_hook" />
+  <hook module="Zope.ComponentArchitecture"
+        name="getServiceManager"
+        implementation=".hooks.getServiceManager_hook" />
+  <hook module="Zope.ComponentArchitecture"
+        name="getNextServiceManager"
+        implementation=".hooks.getNextServiceManager_hook" />
 
 </zopeConfigure>