[Zope-Checkins] CVS: Zope3/lib/python/Zope/Security - Proxy.py:1.1.2.4
Jeremy Hylton
jeremy@zope.com
Wed, 17 Apr 2002 18:58:34 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Security
In directory cvs.zope.org:/tmp/cvs-serv28413
Modified Files:
Tag: SecurityProxy-branch
Proxy.py
Log Message:
Another attempt at a working proxy
=== Zope3/lib/python/Zope/Security/Proxy.py 1.1.2.3 => 1.1.2.4 ===
+import types
+
+descr_type = type(type.__call__)
+method_wrapper = type("abc".lower)
+
class Proxy:
def __init__(self, object, checker=None):
self.object = object
+ def __repr__(self):
+ return repr(self.object)
+
def __call__(self, *args, **kw):
- try:
- return getattr(self.object, '__call__')(*args, **kw)
- except TypeError, msg:
- msg = str(msg)
- if (msg.find("descriptor") != -1
- and msg.find("requires") != -1):
- f = getattr(self.object, '__call__')
- return f(self.object, *args, **kw)
- raise
+ return Proxy(self.object(*args, **kw))
def __getattr__(self, attr):
return Proxy(getattr(self.object, attr), None)