[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ServiceManager - ServiceManager.py:1.1.2.6.2.1 hooks.py:1.1.2.2.2.1
Jim Fulton
jim@zope.com
Fri, 26 Apr 2002 14:23:17 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv26237/lib/python/Zope/App/OFS/ServiceManager
Modified Files:
Tag: SecurityProxy-branch
ServiceManager.py hooks.py
Log Message:
Changed security code to use security proxies and name-based
security. This has pretty far-reaching implications:
- You now protect names/operations, *not* values. This means it's as
easy yo protect data attributes that have simple values as it is to
protect methods.
- There is no longer a __permissions__ attribute. :)
- There is no longer a validate method in either security managers or
policies.
- No more need to have a special compiler for restricted code.
In exchange, lots of objects are proxies and code sometimes needs to
be prepared to remove proxies.
In addition:
- Basic objects (None, strings, numbers, etc.) are not wrapped in
context wrappers.
- There is a test that fails unless Python 2.3 is used.
=== Zope3/lib/python/Zope/App/OFS/ServiceManager/ServiceManager.py 1.1.2.6 => 1.1.2.6.2.1 ===
from Zope.Exceptions import NotFoundError, ZopeError
from Zope.App.OFS.Folder.Folder import Folder
-from Zope.ContextWrapper import getinnercontext, Wrapper
+from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.App.OFS.Container.BTreeContainer import BTreeContainer
class ServiceManager(BTreeContainer):
@@ -60,7 +60,7 @@
service = self.__bindings.get(name)
if service:
- return Wrapper(self.getObject(service), self, name=name)
+ return ContextWrapper(self.getObject(service), self, name=name)
# we don't need to check security, do we?
return getNextService(self, name)
=== Zope3/lib/python/Zope/App/OFS/ServiceManager/hooks.py 1.1.2.2 => 1.1.2.2.2.1 ===
from Zope.ComponentArchitecture.IServiceService import IServiceService
from Zope.ComponentArchitecture.IServiceManagerContainer import IServiceManagerContainer
-from Zope.ContextWrapper import getinnercontext
+from Zope.Proxy.ContextWrapper import getWrapperContainer
from Zope.ComponentArchitecture import getGlobalServiceManager, \
getServiceManager
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
from Zope.ComponentArchitecture.Service import serviceManager
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
def getServiceManager_hook(context):
"""
@@ -30,13 +31,15 @@
"""
while context is not None:
# if the context is actually a service or service manager...
- if IServiceService.isImplementedBy(context): return context
- if IServiceManagerContainer.isImplementedBy(context):
+ if IServiceService.isImplementedBy(removeAllProxies(context)):
+ return context
+ if IServiceManagerContainer.isImplementedBy(
+ removeAllProxies(context)):
try:
return context.getServiceManager()
except ComponentLookupError:
pass
- context = getinnercontext(context)
+ context = getWrapperContainer(context)
return getGlobalServiceManager()
def getNextServiceManager_hook(context):
@@ -44,10 +47,10 @@
to return the next highest service manager"""
context=getServiceManager(context)
if context is serviceManager: return None
- context=getinnercontext(context)
+ context=getWrapperContainer(context)
while context and not IServiceManagerContainer.isImplementedBy(context):
- context=getinnercontext(context) # we should be
+ context=getWrapperContainer(context) # we should be
# able to rely on the first step getting us a
# ServiceManagerContainer
- context=getinnercontext(context)
- return getServiceManager(context)
\ No newline at end of file
+ context=getWrapperContainer(context)
+ return getServiceManager(context)