[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - IToIRegistry.py:1.1.4.16.6.1 hooks.py:1.1.2.22.2.1

Jim Fulton jim@zope.com
Fri, 26 Apr 2002 14:23:22 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv26237/lib/python/Zope/ComponentArchitecture

Modified Files:
      Tag: SecurityProxy-branch
	IToIRegistry.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/ComponentArchitecture/IToIRegistry.py 1.1.4.16 => 1.1.4.16.6.1 ===
 from Exceptions import Invalid
 from types import ListType, TupleType
-
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
 
 class IToIRegistry:  # Interface to Interface
     
@@ -155,7 +155,7 @@
         return result
 
     def getForObject(self, ob, provided):
-        for i in objectImplements(ob):
+        for i in objectImplements(removeAllProxies(ob)):
             c=self.get(i, provided)
             if c is not None: return c
         return self.get(None, provided)
@@ -168,7 +168,7 @@
         """
         result = []
         seen = {}
-        for i in objectImplements(ob):
+        for i in objectImplements(removeAllProxies(ob)):
             self.getAll(i, provided, result, seen)
 
         return self.getAll(None, provided, result, seen)
@@ -229,10 +229,10 @@
         self._registerAll(require, None, data, None)
 
     def getForObject(self, ob):
-        return IToIRegistry.getForObject(self, ob, None)
+        return IToIRegistry.getForObject(self, removeAllProxies(ob), None)
 
     def getAllForObject(self, ob):
-        return IToIRegistry.getAllForObject(self, ob, None)
+        return IToIRegistry.getAllForObject(self, removeAllProxies(ob), None)
 
     def getForType(self, interface):
         return self.get(interface, None)


=== Zope3/lib/python/Zope/ComponentArchitecture/hooks.py 1.1.2.22 => 1.1.2.22.2.1 ===
 from Exceptions import ComponentLookupError
 from Service import serviceManager
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
 
 _marker=[]
 def provideAdapter(forInterface, providedInterface, maker):
@@ -122,7 +123,7 @@
 
 
 def provideFactory_hook(qname, factory):
-    _verify(_IFactory, factory)
+    _verify(_IFactory, removeAllProxies(factory))
     _factories[qname] = factory
 
 def createObject_hook(place, name, args=[], kwargs={}):