Revision 1890
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/Proxy.py | ||
---|---|---|
1 | 1 |
# Proxy object |
2 | 2 |
|
3 | 3 |
class Proxy: |
4 |
'''A proxy that forwards all accesses to an inner object''' |
|
4 |
'''A proxy that forwards all accesses to an inner object. |
|
5 |
Note that it does not forward attribute assignments. |
|
6 |
''' |
|
5 | 7 |
|
6 | 8 |
def __init__(self, inner): self.inner = inner |
7 | 9 |
|
8 |
def __getattr__(self, attr): return self.inner.__getattr__(attr)
|
|
10 |
def __getattr__(self, attr): return getattr(self.inner, attr)
|
|
9 | 11 |
|
10 |
def __setattr__(self, attr, value): |
|
11 |
return self.inner.__setattr__(attr, value) |
|
12 |
# Don't override __setattr__() because it prevents the subclass from storing |
|
13 |
# its own instance variables using "self." syntax |
Also available in: Unified diff
Proxy.py: Fixed infinite recursion bug by removing setattr() (which prevents the class and subclasses from storing instance variables using "self." syntax)