Skip to content

Commit

Permalink
Fixed all attr access: __getattr__, __setattr__, __delattr__.
Browse files Browse the repository at this point in the history
The main work consisted of making sure that access is allowed and that
results are also proxied.
  • Loading branch information
strichter committed Mar 11, 2013
1 parent 19f01d5 commit 4d01d7f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/zope/security/proxy.py
Expand Up @@ -81,19 +81,28 @@ def __getattribute__(self, name):
return checker
if name not in ['__cmp__', '__hash__', '__bool__']:
checker.check_getattr(wrapped, name)
return super(ProxyPy, self).__getattribute__(name)
return checker.proxy(super(ProxyPy, self).__getattribute__(name))

def __getattr__(self, name):
return getattr(self._wrapped, name)
wrapped = super(PyProxyBase, self).__getattribute__('_wrapped')
checker = super(PyProxyBase, self).__getattribute__('_checker')
checker.check_getattr(wrapped, name)
return checker.proxy(getattr(self._wrapped, name))

def __setattr__(self, name, value):
if name in ('_wrapped', '_checker'):
return super(PyProxyBase, self).__setattr__(name, value)
wrapped = super(PyProxyBase, self).__getattribute__('_wrapped')
checker = super(PyProxyBase, self).__getattribute__('_checker')
checker.check_setattr(wrapped, name)
setattr(self._wrapped, name, value)

def __delattr__(self, name):
if name in ('_wrapped', '_checker'):
raise AttributeError()
wrapped = super(PyProxyBase, self).__getattribute__('_wrapped')
checker = super(PyProxyBase, self).__getattribute__('_checker')
checker.check_setattr(wrapped, name)
delattr(self._wrapped, name)

def __cmp__(self, other):
Expand Down

0 comments on commit 4d01d7f

Please sign in to comment.