[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security/tests - testChecker.py:1.1.2.6 testRestrictedInterpreter.py:1.1.2.9 test_Proxy.py:1.1.2.14

Jim Fulton jim@zope.com
Tue, 23 Apr 2002 11:06:47 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv4165/lib/python/Zope/Security/tests

Modified Files:
      Tag: SecurityProxy-branch
	testChecker.py testRestrictedInterpreter.py test_Proxy.py 
Log Message:
Refactored Zope.Security.Proxy names.

Zope.Security.Proxy.Proxy is the Proxy type.

Zope.Security.Proxy.ProxyFactory is the factory that selects a checker
and creates a proxy for an object. 

This thing introduces an odd dependency on the Checker module. Maybe
the ProxyFactory should only be in the Checker module.

Zope.Security.Proxy.getObject is a function that gets the object
proxied by a proxy.

Zope.Security.Proxy.getChecker is a function that gets the checker
used by a proxy.



=== Zope3/lib/python/Zope/Security/tests/testChecker.py 1.1.2.5 => 1.1.2.6 ===
 from Zope.Exceptions import Forbidden, Unauthorized
 from Zope.App.Security.SecurityManagement import setSecurityPolicy
-from Zope.Security._Proxy import getChecker, getObject
+from Zope.Security.Proxy import getChecker, getObject
 from Zope.Security.Checker import defineChecker
-from Zope.Security.Proxy import Proxy
 
 class SecurityPolicy:
 


=== Zope3/lib/python/Zope/Security/tests/testRestrictedInterpreter.py 1.1.2.8 => 1.1.2.9 ===
 
-import Zope.Security.Proxy
-
 from Zope.Security.RestrictedInterpreter import RestrictedInterpreter
-from Zope.Security.Proxy import Proxy
+from Zope.Security.Proxy import ProxyFactory
 from Zope.Security.Checker import defineChecker
 
 from Zope.Testing.CleanUp import cleanUp
@@ -14,7 +12,7 @@
     def check(self, object, opname):
         pass
     def proxy(self, value):
-        return Proxy(value)
+        return ProxyFactory(value)
 
 class RITests(unittest.TestCase):
 
@@ -35,10 +33,15 @@
         # make sure we've really got proxies
         import types
         from Zope.Security.Checker import NamesChecker
+
         checker = NamesChecker(['Proxy'])
+
+        import Zope.Security.Proxy
         defineChecker(Zope.Security.Proxy, checker)
+
         checker = NamesChecker(['BuiltinFunctionType'])
         defineChecker(types, checker)
+
         code = ("from Zope.Security.Proxy import Proxy\n"
                 "import types\n"
                 "assert type(id) is not types.BuiltinFunctionType\n"


=== Zope3/lib/python/Zope/Security/tests/test_Proxy.py 1.1.2.13 => 1.1.2.14 ===
 from Zope.Exceptions import Forbidden
-from Zope.Security._Proxy import getObject, getChecker
-from Zope.Security.Proxy import Proxy
+from Zope.Security.Proxy import getObject, getChecker, ProxyFactory
 
 class Checker:
 
@@ -22,7 +21,7 @@
     def proxy(self, value):
         if type(value) is str:
             return value
-        return Proxy(value, self)
+        return ProxyFactory(value, self)
 
 
 class Something:
@@ -57,7 +56,7 @@
     def setUp(self):
         self.x = Something()
         self.c = Checker()
-        self.p = Proxy(self.x, self.c)
+        self.p = ProxyFactory(self.x, self.c)
 
     def shouldFail(self, *args):
         self.c.ok = 0
@@ -174,14 +173,14 @@
         class C:
             pass
         d = {C: C()}
-        pC = Proxy(C, self.c)
+        pC = ProxyFactory(C, self.c)
         self.assertEqual(d[pC], d[C])
 
     def testProxiedNewClassAsDictKey(self):
         class C(object):
             pass
         d = {C: C()}
-        pC = Proxy(C, self.c)
+        pC = ProxyFactory(C, self.c)
         self.assertEqual(d[pC], d[C])
 
 def test_suite():