SCons :: Util :: Proxy :: Class Proxy
[hide private]
[frames] | no frames]

Class Proxy

source code

object --+
Known Subclasses:

A simple generic Proxy class, forwarding all calls to subject. So, for the benefit of the python newbie, what does this really mean? Well, it means that you can take an object, let's call it 'objA', and wrap it in this Proxy class, with a statement like this

proxyObj = Proxy(objA),

Then, if in the future, you do something like this

x = proxyObj.var1,

since Proxy does not have a 'var1' attribute (but presumably objA does), the request actually is equivalent to saying

x = objA.var1

Inherit from this class to create a Proxy.

Note that, with new-style classes, this does not work transparently for Proxy subclasses that use special .__*__() method names, because those names are now bound to the class, not the individual instances. You now need to know in advance which .__*__() method names you want to pass on to the underlying Proxy object, and specifically delegate their calls like this:

class Foo(Proxy):
__str__ = Delegate('__str__')
Instance Methods [hide private]
__init__(self, subject)
Wrap an object as a Proxy object
source code
__getattr__(self, name)
Retrieve an attribute from the wrapped object. If the named attribute doesn't exist, AttributeError is raised
source code
Retrieve the entire wrapped object
source code
__cmp__(self, other) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, subject)

source code 
Wrap an object as a Proxy object
Overrides: object.__init__