[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/ use removeSecurityProxy() instead of removeAllProxies() in many places

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


Log message for revision 27260:
  use removeSecurityProxy() instead of removeAllProxies() in many places


Changed:
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directives.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_fileresource.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_icondirective.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/registration/browser/__init__.py


-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py	2004-08-25 14:02:26 UTC (rev 27259)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publication/zopepublication.py	2004-08-25 14:59:38 UTC (rev 27260)
@@ -25,7 +25,6 @@
 from zope.security.interfaces import Unauthorized
 from zope.component.exceptions import ComponentLookupError
 from zope.interface import implements, providedBy
-from zope.proxy import removeAllProxies
 from zope.publisher.publish import mapply
 from zope.publisher.interfaces import Retry, IExceptionSideEffects
 from zope.publisher.interfaces import IRequest, IPublication
@@ -88,7 +87,7 @@
             # We won't find an authentication service here, so give up.
             return
 
-        sm = removeAllProxies(ob).getSiteManager()
+        sm = removeSecurityProxy(ob).getSiteManager()
 
         try:
             auth_service = sm.getService(zapi.servicenames.Authentication)
@@ -277,7 +276,7 @@
                 # an im_self or a __self__, use it. 
                 loc = object
                 if not hasattr(object, '__parent__'):
-                    loc = removeAllProxies(object)
+                    loc = removeSecurityProxy(object)
                     # Try to get an object, since we apparently have a method
                     # Note: We are guaranteed that an object has a location,
                     # so just getting the instance the method belongs to is

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directives.py	2004-08-25 14:02:26 UTC (rev 27259)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directives.py	2004-08-25 14:59:38 UTC (rev 27260)
@@ -30,7 +30,7 @@
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.security.proxy import ProxyFactory
 import zope.security.management
-from zope.proxy import removeAllProxies
+from zope.security.proxy import removeSecurityProxy
 
 from zope.app.publisher.browser.globalbrowsermenuservice import \
     globalBrowserMenuService
@@ -519,15 +519,15 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request)[1], (u'index.html', ))
 
 
         v = view.publishTraverse(request, 'index.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(v(), 'V1 here')
         v = view.publishTraverse(request, 'action.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(v(), 'done')
 
 
@@ -546,7 +546,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request), (view, ()))
 
     def testNamedViewNoPagesForNonCallable(self):
@@ -564,7 +564,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         self.assertEqual(getattr(view, 'browserDefault', None), None)
 
     def testNamedViewPageViewsNoDefault(self):
@@ -588,18 +588,18 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request)[1], (u'index.html', ))
 
 
         v = view.publishTraverse(request, 'index.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(v(), 'V1 here')
         v = view.publishTraverse(request, 'action.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(v(), 'done')
         v = view.publishTraverse(request, 'test.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
 
     def testNamedViewPageViewsWithDefault(self):
@@ -624,18 +624,18 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request)[1], (u'test.html', ))
 
 
         v = view.publishTraverse(request, 'index.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(v(), 'V1 here')
         v = view.publishTraverse(request, 'action.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(v(), 'done')
         v = view.publishTraverse(request, 'test.html')
-        v = removeAllProxies(v)
+        v = removeSecurityProxy(v)
         self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
 
     def testTraversalOfPageForView(self):
@@ -657,7 +657,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         view.publishTraverse(request, 'index.html')
         
     def testTraversalOfPageForViewWithPublishTraverse(self):
@@ -684,7 +684,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         view.publishTraverse(request, 'index.html')
 
     def testProtectedPageViews(self):
@@ -814,7 +814,7 @@
 
         self.assertRaises(Exception, getattr, r, '_testData')
 
-        r = removeAllProxies(r)
+        r = removeSecurityProxy(r)
         self.assert_(r.__class__ is FileResource)
         self.assertEqual(r._testData(), open(path, 'rb').read())
 
@@ -838,7 +838,7 @@
         self.assertEqual(queryResource('test', request), None)
 
         r = getResource('test', TestRequest(skin='zmi'))
-        r = removeAllProxies(r)
+        r = removeSecurityProxy(r)
         self.assertEqual(r._testData(), open(path, 'rb').read())
 
     def test_template_page(self):

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py	2004-08-25 14:02:26 UTC (rev 27259)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py	2004-08-25 14:59:38 UTC (rev 27260)
@@ -19,7 +19,8 @@
 from unittest import TestCase, main, makeSuite
 
 from zope.exceptions import NotFoundError
-from zope.proxy import isProxy, removeAllProxies
+from zope.proxy import isProxy
+from zope.security.proxy import removeSecurityProxy
 from zope.publisher.browser import TestRequest
 from zope.security.checker import NamesChecker, ProxyFactory
 from zope.interface import implements
@@ -98,13 +99,14 @@
         resource = DirectoryResourceFactory(path, checker, 'files')(request)
 
         image = resource['test.gif']
-        self.assert_(isinstance(removeAllProxies(image), FileResource))
+        self.assert_(isinstance(removeSecurityProxy(image), FileResource))
         template = resource['test.pt']
-        self.assert_(isinstance(removeAllProxies(template), PageTemplateResource))
+        self.assert_(isinstance(removeSecurityProxy(template),
+                                PageTemplateResource))
         file = resource['test.txt']
-        self.assert_(isinstance(removeAllProxies(file), FileResource))
+        self.assert_(isinstance(removeSecurityProxy(file), FileResource))
         file = resource['png']
-        self.assert_(isinstance(removeAllProxies(file), FileResource))
+        self.assert_(isinstance(removeSecurityProxy(file), FileResource))
 
 def test_suite():
     return makeSuite(Test)

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_fileresource.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_fileresource.py	2004-08-25 14:02:26 UTC (rev 27259)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_fileresource.py	2004-08-25 14:59:38 UTC (rev 27260)
@@ -20,7 +20,7 @@
 
 from zope.exceptions import NotFoundError
 from zope.i18n.interfaces import IUserPreferredCharsets
-from zope.proxy import removeAllProxies
+from zope.security.proxy import removeSecurityProxy
 from zope.security.checker import NamesChecker
 
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -65,7 +65,7 @@
         resource = factory(TestRequest())
         self.assertEqual(resource.GET(), open(path, 'rb').read())
 
-        response = removeAllProxies(resource.request).response
+        response = removeSecurityProxy(resource.request).response
         self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
 
     def testFileHEAD(self):
@@ -76,7 +76,7 @@
 
         self.assertEqual(resource.HEAD(), '')
 
-        response = removeAllProxies(resource.request).response
+        response = removeSecurityProxy(resource.request).response
         self.assertEqual(response.getHeader('Content-Type'), 'text/plain')
 
     def testImageGET(self):
@@ -88,7 +88,7 @@
 
         self.assertEqual(resource.GET(), open(path, 'rb').read())
 
-        response = removeAllProxies(resource.request).response
+        response = removeSecurityProxy(resource.request).response
         self.assertEqual(response.getHeader('Content-Type'), 'image/gif')
 
     def testImageHEAD(self):
@@ -99,7 +99,7 @@
 
         self.assertEqual(resource.HEAD(), '')
 
-        response = removeAllProxies(resource.request).response
+        response = removeSecurityProxy(resource.request).response
         self.assertEqual(response.getHeader('Content-Type'), 'image/gif')
 
 

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_icondirective.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_icondirective.py	2004-08-25 14:02:26 UTC (rev 27259)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_icondirective.py	2004-08-25 14:59:38 UTC (rev 27260)
@@ -23,7 +23,7 @@
 from zope.configuration.exceptions import ConfigurationError
 from zope.configuration.xmlconfig import xmlconfig, XMLConfig
 from zope.interface import implements
-from zope.proxy import removeAllProxies
+from zope.security.proxy import removeSecurityProxy
 from zope.publisher.browser import TestRequest
 from zope.security.checker import ProxyFactory, CheckerPublic
 from zope.security.interfaces import Forbidden
@@ -94,7 +94,7 @@
 
         resource = ProxyFactory(getResource(rname, request))
         self.assertRaises(Forbidden, getattr, resource, '_testData')
-        resource = removeAllProxies(resource)
+        resource = removeSecurityProxy(resource)
         self.assertEqual(resource._testData(), open(path, 'rb').read())
 
     def testResource(self):
@@ -125,7 +125,7 @@
         resource = ProxyFactory(getResource(rname, request))
 
         self.assertRaises(Forbidden, getattr, resource, '_testData')
-        resource = removeAllProxies(resource)
+        resource = removeSecurityProxy(resource)
         self.assertEqual(resource._testData(), open(path, 'rb').read())
 
     def testResourceErrors(self):

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/registration/browser/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/registration/browser/__init__.py	2004-08-25 14:02:26 UTC (rev 27259)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/registration/browser/__init__.py	2004-08-25 14:59:38 UTC (rev 27260)
@@ -30,7 +30,7 @@
 from zope.app.traversing.api import getName, traverse
 from zope.component import getView, getServices
 from zope.interface import implements
-from zope.proxy import removeAllProxies
+from zope.security.proxy import removeSecurityProxy
 
 class RegistrationView(BrowserView):
 
@@ -129,7 +129,7 @@
         registrations = self.context.info()
 
         # This is OK because registrations is just a list of dicts
-        registrations = removeAllProxies(registrations)
+        registrations = removeSecurityProxy(registrations)
 
         inactive = 1
         for info in registrations:



More information about the Zope3-Checkins mailing list