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

Jeremy Hylton jeremy@zope.com
Wed, 17 Apr 2002 18:29:50 -0400


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

Modified Files:
      Tag: SecurityProxy-branch
	Proxy.py 
Log Message:
A new replaceable proxy implementation


=== Zope3/lib/python/Zope/Security/Proxy.py 1.1.2.1 => 1.1.2.2 ===
 
-from Zope.ContextWrapper import Wrapper
+class Proxy:
+    def __init__(self, object, checker=None):
+        self.object = object
+
+    def __call__(self, *args, **kw):
+        return getattr(self.object, '__call__')(*args, **kw)
+
+    def __getattr__(self, attr):
+        return Proxy(getattr(self.object, attr), None)
+
+    def __getitem__(self, i):
+        return Proxy(self.object[i], None)
 
-def Proxy(obj):
-    return Wrapper(obj)