[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager - hooks.py:1.1.4.1.2.2
Jim Fulton
jim@zope.com
Thu, 6 Jun 2002 17:48:53 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv19481/lib/python/Zope/App/OFS/Services/ServiceManager
Modified Files:
Tag: Zope3InWonderland-branch
hooks.py
Log Message:
Added a new method, trustedRemoveSecurityProxy that removes
security proxies from "trusted" objects.
The code for getting service managers calls this when a service
manager found is trusted. The placeful service manager will need to
call this for trusted services and placeful component managers will
need to do so for trusted components.
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/hooks.py 1.1.4.1.2.1 => 1.1.4.1.2.2 ===
from Zope.ComponentArchitecture.GlobalServiceManager import serviceManager
from Zope.Proxy.ProxyIntrospection import removeAllProxies
+from Zope.Security.Proxy import trustedRemoveSecurityProxy
def getServiceManager_hook(context):
"""
@@ -30,26 +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="etc::Services")
+ 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)