[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security - Proxy.py:1.1.2.7

Guido van Rossum guido@python.org
Thu, 18 Apr 2002 11:49:53 -0400


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

Modified Files:
      Tag: SecurityProxy-branch
	Proxy.py 
Log Message:
Use the real _Proxy class instead of a dummy.


=== Zope3/lib/python/Zope/Security/Proxy.py 1.1.2.6 => 1.1.2.7 ===
+import types
+from Zope.Security._Proxy import _Proxy
 
 def Proxy(obj, checker=None):
     if obj is None:
@@ -7,27 +8,10 @@
         return obj
     elif isinstance(obj, float):
         return obj
+    elif isinstance(obj, _Proxy):
+        return obj
+    elif isinstance(obj, types.ClassType) and issubclass(obj, Exception):
+        # XXX can't wrap exceptions because we can't raise proxies
+        return obj
     else:
         return _Proxy(obj, checker)
-
-class _Proxy:
-    def __init__(self, object, checker):
-        self.object = object
-
-    def __repr__(self):
-        return repr(self.object)
-
-    def __str__(self):
-        return str(self.object)
-
-    def __call__(self, *args, **kw):
-        return Proxy(self.object(*args, **kw))
-
-    def __getattr__(self, attr):
-        return Proxy(getattr(self.object, attr), None)
-
-    def __getitem__(self, i):
-        return Proxy(self.object[i], None)
-
-    def __cmp__(self, object):
-        return cmp(self.object, object)