[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ServiceManager - ServiceManager.py:1.1.2.10 hooks.py:1.1.2.5
Gary Poster
garyposter@earthlink.net
Thu, 2 May 2002 13:18:20 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv28126/lib/python/Zope/App/OFS/ServiceManager
Modified Files:
Tag: Zope-3x-branch
ServiceManager.py hooks.py
Log Message:
Several interfaces divided up into readers (getters) and writers (setters), then used in the zcml for permissions. Some small changes in the local ServiceManager to deal with the new security a bit better, hopefully. Fixed Image enough so that you can upload one, but I'm getting a server buffer error when I try to view it. The change to ZMIViewUtility I'm not sure of, but it made sense to me.
You can now add, edit, and view significantly more of the content since the security changes.
=== Zope3/lib/python/Zope/App/OFS/ServiceManager/ServiceManager.py 1.1.2.9 => 1.1.2.10 ===
from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.App.OFS.Container.BTreeContainer import BTreeContainer
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
class ServiceManager(BTreeContainer):
@@ -39,6 +40,7 @@
def getServiceDefinitions(wrapped_self):
+ clean_self=removeAllProxies(wrapped_self)
""" see IServiceManager Interface """
# Get the services defined here and above us, if any (as held
# in a ServiceInterfaceService, presumably)
@@ -51,23 +53,26 @@
# an interface service evetually though...so this would be useful then:
serviceInterfaceServ= \
- wrapped_self.__bindings.get('ServiceInterfaceService')
+ clean_self.__bindings.get('ServiceInterfaceService')
if serviceInterfaceServ:
serviceDefs.update(dict(
- wrapped_self.getObject(serviceInterfaceServ).objectItems()))
+ removeAllProxies(
+ wrapped_self.getObject(serviceInterfaceServ).objectItems()
+ )
+ ))
return serviceDefs
getServiceDefinitions=ContextMethod(getServiceDefinitions)
def getService(wrapped_self, name):
""" see IServiceManager Interface"""
+ clean_self=removeAllProxies(wrapped_self)
- service = wrapped_self.__bindings.get(name)
+ service = clean_self.__bindings.get(name)
if service:
return ContextWrapper(wrapped_self.getObject(service),
wrapped_self, name=name)
- # XXX we don't need to check security, do we?
return getNextService(wrapped_self, name)
@@ -78,13 +83,18 @@
return self.__bindings.get(name)
- def bindService(self, serviceName, serviceComponentName):
+ def bindService(wrapped_self, serviceName, serviceComponentName):
""" see IServiceManager Interface"""
+ clean_self=removeAllProxies(wrapped_self)
# This could raise a KeyError if we don't have this component
- serviceComponent = self.getObject(serviceComponentName)
+ serviceComponent = removeAllProxies(
+ wrapped_self.getObject(
+ serviceComponentName
+ )
+ )
- for name,interface in self.getServiceDefinitions():
+ for name,interface in wrapped_self.getServiceDefinitions():
if name == serviceName:
if not interface.isImplementedBy(serviceComponent):
raise InvalidService(serviceName,
@@ -96,9 +106,9 @@
# self.setObject(name, component)
# trigger persistence
- self.__bindings = self.__bindings
+ clean_self.__bindings = clean_self.__bindings
- self.__bindings[serviceName] = serviceComponentName
+ clean_self.__bindings[serviceName] = serviceComponentName
bindService=ContextMethod(bindService) # needed because of call to
# getServiceDefinitions
=== Zope3/lib/python/Zope/App/OFS/ServiceManager/hooks.py 1.1.2.4 => 1.1.2.5 ===
"""
from Zope.ComponentArchitecture.IServiceManager import IServiceManager
-from Zope.ComponentArchitecture.IServiceManagerContainer import IServiceManagerContainer
+from Zope.ComponentArchitecture.IServiceManagerContainer import \
+ IServiceManagerContainer
from Zope.Proxy.ContextWrapper import getWrapperContainer, ContextWrapper
from Zope.ComponentArchitecture import getServiceManager
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
@@ -29,15 +30,13 @@
service manager if no service manager found within context
"""
while context is not None:
+ clean_context=removeAllProxies(context)
# if the context is actually a service or service manager...
- if IServiceManager.isImplementedBy(removeAllProxies(context)):
+ if IServiceManager.isImplementedBy(clean_context):
return context
if IServiceManagerContainer.isImplementedBy(
- removeAllProxies(context)):
- try:
- return context.getServiceManager()
- except ComponentLookupError:
- pass
+ clean_context) and clean_context.hasServiceManager():
+ return context.getServiceManager()
context = getWrapperContainer(context)
return serviceManager
@@ -48,9 +47,7 @@
if context is serviceManager: return None
context=getWrapperContainer(context)
while context and not \
- IServiceManagerContainer.isImplementedBy(
- removeAllProxies(context)
- ):
+ IServiceManagerContainer.isImplementedBy(context):
context=getWrapperContainer(context) # we should be
# able to rely on the first step getting us a
# ServiceManagerContainer