5
class AttributeAccess(object):
6
def __init__(self, container, accessor='__getattr__'):
9
# XXXXXXXXXXXX WARNING XXXXXXXXXXXXXX
10
# The back reference to the container should be weak
11
# because if not, that would create a circular reference,
12
# and NestedRecArray ultimately inherits from
13
# numarray._ndarray._ndarray extension that have a dealloc
14
# and this is equivalent to a __del__ method, so the
15
# garbage collector does not work well in these situations
16
# XXXXXXXXXXXX WARNING XXXXXXXXXXXXXX
17
#mydict['__container'] = container
18
mydict['__container'] = weakref.ref(container)
19
mydict['__accessor'] = accessor
22
def __getattr__(self, name):
23
# XXXXXXXXXXXX WARNING XXXXXXXXXXXXXX
24
# The back reference to the container should be weak
25
# because if not, that would create a circular reference,
26
# and NestedRecArray ultimately inherits from
27
# numarray._ndarray._ndarray extension that have a dealloc
28
# and this is equivalent to a __del__ method, so the
29
# garbage collector does not work well in these situations
30
# XXXXXXXXXXXX WARNING XXXXXXXXXXXXXX
31
#container = self.__dict__['__container']
32
container = self.__dict__['__container']()
33
accessor = self.__dict__['__accessor']
34
return getattr(container, accessor)(name)
40
## py-indent-offset: 4