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

Fred L. Drake, Jr. fdrake at gmail.com
Wed Aug 25 11:19:32 EDT 2004


Log message for revision 27261:
  use removeSecurityProxy() instead of removeAllProxies() in many places
  
  (merged from ZopeX3-3.0 branch revision 27260)
  


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


-=-
Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py	2004-08-25 14:59:38 UTC (rev 27260)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py	2004-08-25 15:19:32 UTC (rev 27261)
@@ -27,7 +27,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
@@ -90,7 +89,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)
@@ -279,7 +278,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/trunk/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py	2004-08-25 14:59:38 UTC (rev 27260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py	2004-08-25 15:19:32 UTC (rev 27261)
@@ -29,7 +29,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
@@ -530,15 +530,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')
 
 
@@ -557,7 +557,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         self.assertEqual(view.browserDefault(request), (view, ()))
 
     def testNamedViewNoPagesForNonCallable(self):
@@ -575,7 +575,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         self.assertEqual(getattr(view, 'browserDefault', None), None)
 
     def testNamedViewPageViewsNoDefault(self):
@@ -599,18 +599,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):
@@ -635,18 +635,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):
@@ -668,7 +668,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         view.publishTraverse(request, 'index.html')
         
     def testTraversalOfPageForViewWithPublishTraverse(self):
@@ -695,7 +695,7 @@
             ))
 
         view = getView(ob, 'test', request)
-        view = removeAllProxies(view)
+        view = removeSecurityProxy(view)
         view.publishTraverse(request, 'index.html')
 
     def testProtectedPageViews(self):
@@ -815,7 +815,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())
 
@@ -839,7 +839,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/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py	2004-08-25 14:59:38 UTC (rev 27260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py	2004-08-25 15:19:32 UTC (rev 27261)
@@ -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/trunk/src/zope/app/publisher/browser/tests/test_fileresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_fileresource.py	2004-08-25 14:59:38 UTC (rev 27260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_fileresource.py	2004-08-25 15:19:32 UTC (rev 27261)
@@ -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/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py	2004-08-25 14:59:38 UTC (rev 27260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py	2004-08-25 15:19:32 UTC (rev 27261)
@@ -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
@@ -93,7 +93,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):
@@ -124,7 +124,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/trunk/src/zope/app/registration/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/registration/browser/__init__.py	2004-08-25 14:59:38 UTC (rev 27260)
+++ Zope3/trunk/src/zope/app/registration/browser/__init__.py	2004-08-25 15:19:32 UTC (rev 27261)
@@ -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