[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/ remove many calls to removeAllProxies(), and replace others with

Fred L. Drake, Jr. fdrake at gmail.com
Wed Aug 25 15:14:10 EDT 2004


Log message for revision 27267:
  remove many calls to removeAllProxies(), and replace others with
  removeSecurityProxy()
  


Changed:
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/interface/__init__.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/__init__.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/browser.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publication/browser.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publication/publicationtraverse.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publication/tests/test_browserpublication.py


-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/interface/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/interface/__init__.py	2004-08-25 19:01:44 UTC (rev 27266)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/interface/__init__.py	2004-08-25 19:14:10 UTC (rev 27267)
@@ -17,8 +17,6 @@
 
 $Id$
 """
-from zope.proxy import removeAllProxies
-
 from zope.interface.declarations import providedBy
 
 def queryType(object, interface):
@@ -79,8 +77,6 @@
     'I4'
 
     """
-    object = removeAllProxies(object)
-    
     object_iro = providedBy(object).__iro__
     for iface in object_iro:
         if interface.providedBy(iface):

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/__init__.py	2004-08-25 19:01:44 UTC (rev 27266)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/__init__.py	2004-08-25 19:14:10 UTC (rev 27267)
@@ -18,11 +18,11 @@
 from zope.interface import Interface
 from zope.app.introspector.interfaces import IIntrospector
 from zope.component import getService, getServiceDefinitions, getServices
-from zope.proxy import removeAllProxies
 from zope.interface import implements, implementedBy
 from zope.interface import directlyProvides, directlyProvidedBy, providedBy
 from zope.interface.interfaces import IInterface
 from zope.interface.interface import InterfaceClass
+from zope.security.proxy import removeSecurityProxy
 from zope.app.component.interface import searchInterface, getInterface
 
 class Introspector(object):
@@ -70,7 +70,7 @@
 
     def getClass(self):
         """Returns the class name"""
-        return removeAllProxies(self.currentclass).__name__
+        return self.currentclass.__name__
 
     def getBaseClassNames(self):
         """Returns the names of the classes"""
@@ -82,15 +82,15 @@
 
     def getModule(self):
         """Returns the module name of the class"""
-        return removeAllProxies(self.currentclass).__module__
+        return self.currentclass.__module__
 
     def getDocString(self):
         """Returns the description of the class"""
-        return removeAllProxies(self.currentclass).__doc__
+        return removeSecurityProxy(self.currentclass).__doc__
 
     def getInterfaces(self):
         """Returns interfaces implemented by this class"""
-        return tuple(implementedBy(removeAllProxies(self.currentclass)))
+        return tuple(implementedBy(self.currentclass))
 
     def getInterfaceNames(self, interfaces=None):
         if interfaces is None:
@@ -114,7 +114,7 @@
             namesAndDescriptions.sort()
             for name, desc in namesAndDescriptions:
                 if hasattr(desc, 'getSignatureString'):
-                    methods.append((desc.getName(),
+                    methods.append((desc.__name__,
                                     desc.getSignatureString(),
                                     desc.getDoc()))
                 else:
@@ -128,7 +128,7 @@
     def getExtends(self):
         """Returns all the class extended up to the top most level"""
         bases = self._unpackTuple(
-            removeAllProxies(self.currentclass).__bases__)
+            removeSecurityProxy(self.currentclass).__bases__)
         return bases
 
     def getInterfaceRegistration(self):
@@ -141,7 +141,7 @@
 
     def getDirectlyProvided(self):
         """See IIntrospector"""
-        return directlyProvidedBy(removeAllProxies(self.context))
+        return directlyProvidedBy(self.context)
 
     def getDirectlyProvidedNames(self):
         """See IIntrospector"""
@@ -157,7 +157,7 @@
         """See IIntrospector"""
 
         results = []
-        todo = list(providedBy(removeAllProxies(self.context)))
+        todo = list(providedBy(self.context))
         done = []
         while todo:
             interface = todo.pop()
@@ -194,7 +194,6 @@
 # TODO: This method should go away and only registered interface utilities
 # should be used.
 def interfaceToName(context, interface):
-    interface = removeAllProxies(interface)
     if interface is None:
         return 'None'
     items = searchInterface(context, base=interface)
@@ -206,7 +205,7 @@
         # Do not fail badly, instead resort to the standard
         # way of getting the interface name, cause not all interfaces
         # may be registered as utilities.
-        return interface.__module__ + '.' + interface.getName()
+        return interface.__module__ + '.' + interface.__name__
 
     assert len(ids) == 1, "Ambiguous interface names: %s" % ids
     return ids[0]

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/browser.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/browser.py	2004-08-25 19:01:44 UTC (rev 27266)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/introspector/browser.py	2004-08-25 19:14:10 UTC (rev 27267)
@@ -20,7 +20,6 @@
 from zope.app import zapi
 from zope.component.exceptions import ComponentLookupError
 from zope.interface import directlyProvides, directlyProvidedBy
-from zope.proxy import removeAllProxies
 from zope.app.component.interface import getInterface
 from zope.app.servicenames import Services
 
@@ -45,15 +44,15 @@
         if 'ADD' in self.request:
             for interface in self.getIntrospector().getMarkerInterfaceNames():
                 if "add_%s" % interface in self.request:
-                    interface = getInterface(self.context, interface)
-                    ob = removeAllProxies(self.context)
+                    ob = self.context
+                    interface = getInterface(ob, interface)
                     directlyProvides(ob, directlyProvidedBy(ob), interface)
 
         if 'REMOVE' in self.request:
             for interface in self.getIntrospector().getDirectlyProvidedNames():
                 if "rem_%s" % interface in self.request:
-                    interface = getInterface(self.context, interface)
-                    ob = removeAllProxies(self.context)
+                    ob = self.context
+                    interface = getInterface(ob, interface)
                     directlyProvides(ob, directlyProvidedBy(ob)-interface)
 
     def getServicesFor(self):

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publication/browser.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publication/browser.py	2004-08-25 19:01:44 UTC (rev 27266)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publication/browser.py	2004-08-25 19:14:10 UTC (rev 27267)
@@ -22,7 +22,6 @@
      import PublicationTraverser as PublicationTraverser_
 from zope.app.publication.http import BaseHTTPPublication
 from zope.component import queryViewProviding
-from zope.proxy import removeAllProxies
 from zope.publisher.interfaces.browser import IBrowserPublisher
 from zope.security.checker import ProxyFactory
 
@@ -46,7 +45,7 @@
     """Web browser publication handling."""
 
     def getDefaultTraversal(self, request, ob):
-        if IBrowserPublisher.providedBy(removeAllProxies(ob)):
+        if IBrowserPublisher.providedBy(ob):
             # ob is already proxied, so the result of calling a method will be
             return ob.browserDefault(request)
         else:

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publication/publicationtraverse.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publication/publicationtraverse.py	2004-08-25 19:01:44 UTC (rev 27266)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publication/publicationtraverse.py	2004-08-25 19:14:10 UTC (rev 27267)
@@ -20,7 +20,6 @@
 from types import StringTypes
 from zope.security.checker import ProxyFactory
 
-from zope.proxy import removeAllProxies
 from zope.app.traversing.namespace import namespaceLookup
 from zope.app.traversing.namespace import nsParse
 from zope.publisher.interfaces import IPublishTraverse
@@ -46,7 +45,7 @@
         if nm == '.':
             return ob
 
-        if IPublishTraverse.providedBy(removeAllProxies(ob)):
+        if IPublishTraverse.providedBy(ob):
             ob2 = ob.publishTraverse(request, nm)
         else:
             # self is marker

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publication/tests/test_browserpublication.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publication/tests/test_browserpublication.py	2004-08-25 19:01:44 UTC (rev 27266)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publication/tests/test_browserpublication.py	2004-08-25 19:14:10 UTC (rev 27267)
@@ -28,8 +28,8 @@
 from zope.app.publisher.browser import BrowserView
 from zope.publisher.interfaces.browser import IBrowserPublisher
 
-from zope.proxy import removeAllProxies, getProxiedObject
-from zope.security.proxy import Proxy
+from zope.proxy import getProxiedObject
+from zope.security.proxy import Proxy, removeSecurityProxy
 from zope.security.checker import defineChecker, NamesChecker
 
 from zope.app.security.principalregistry import principalRegistry
@@ -161,7 +161,6 @@
     def testAdaptedTraverseNameWrapping(self):
 
         class Adapter(object):
-            " "
             implements(IBrowserPublisher)
             def __init__(self, context, request):
                 self.context = context
@@ -178,7 +177,7 @@
         pub = self.klass(self.db)
         ob2 = pub.traverseName(self._createRequest('/bruce', pub), ob, 'bruce')
         self.assertRaises(ForbiddenAttribute, getattr, ob2, 'v')
-        self.assertEqual(removeAllProxies(ob2).v, 'bruce')
+        self.assertEqual(removeSecurityProxy(ob2).v, 'bruce')
 
     def testAdaptedTraverseDefaultWrapping(self):
         # Test default content and make sure that it's wrapped.
@@ -198,7 +197,7 @@
         ob2, x = pub.getDefaultTraversal(self._createRequest('/bruce',pub), ob)
         self.assertEqual(x, 'dummy')
         self.assertRaises(ForbiddenAttribute, getattr, ob2, 'v')
-        self.assertEqual(removeAllProxies(ob2).v, 'bruce')
+        self.assertEqual(removeSecurityProxy(ob2).v, 'bruce')
 
     def testTraverseName(self):
         pub = self.klass(self.db)
@@ -209,7 +208,7 @@
         ztapi.browserViewProviding(None, TestTraverser, IBrowserPublisher)
         ob2 = pub.traverseName(r, ob, 'x')
         self.assertRaises(ForbiddenAttribute, getattr, ob2, 'v')
-        self.assertEqual(removeAllProxies(ob2).v, 1)
+        self.assertEqual(removeSecurityProxy(ob2).v, 1)
 
     def testTraverseNameView(self):
         pub = self.klass(self.db)
@@ -233,7 +232,7 @@
         r = self._createRequest('/++etc++site',pub)
         ob2 = pub.traverseName(r, ob, '++etc++site')
         self.assertRaises(ForbiddenAttribute, getattr, ob2, 'v')
-        self.assertEqual(removeAllProxies(ob2).v, 1)
+        self.assertEqual(removeSecurityProxy(ob2).v, 1)
 
     def testTraverseNameApplicationControl(self):
         from zope.app.applicationcontrol.applicationcontrol \



More information about the Zope3-Checkins mailing list