title: Proxying variables in Python
body: <p>I have a Python object that I want to shield from any inside and outside access and run every request through a proxy. I used <a href="http://code.activestate.com/recipes/496741-object-proxying/" rel="nofollow">this</a> piece of code so far which works fine. I subclass it and initialise it with the object I want to proxy.</p>
  
  <p>Unfortunately, it does not cover the case for which access occurs from within the proxied object.</p>
  
  <pre><code>class A(object):
      def do_something(self):
         self.foo.perform_action()
  
  class MyProxy(Proxy):    
      def __init__(self, obj):
          super(MyProxy, self).__init__(obj)
          self.proxy_foo = ProxyFoo(obj.foo)
  
      def __getattribute__(self, item):
          if item == 'foo':
             return self.proxy_foo
          return super(MyProxy, self).__getattribute__(item)
  
  a = A()
  myproxy = Proxy(a)
  # do_something should work on proxy_foo, but it operates on a.foo
  myproxy.do_something()
  </code></pre>
  
  <p>What can I do to change this?</p>