~ubuntu-branches/ubuntu/natty/pytables/natty-updates

« back to all changes in this revision

Viewing changes to tables/attributeaccess.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2006-06-28 10:45:03 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20060628104503-cc251q5o5j3e2k10
  * Fixed call to pyversions in debian/rules which failed on recent versions 
    of pyversions
  * Fixed clean rule in debian/rules which left the stamp files behind
  * Acknowledge NMU
  * Added Alexandre Fayolle to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import weakref
 
2
 
 
3
 
 
4
 
 
5
class AttributeAccess(object):
 
6
    def __init__(self, container, accessor='__getattr__'):
 
7
        mydict = self.__dict__
 
8
 
 
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
 
20
 
 
21
 
 
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)
 
35
 
 
36
 
 
37
 
 
38
## Local Variables:
 
39
## mode: python
 
40
## py-indent-offset: 4
 
41
## tab-width: 4
 
42
## fill-column: 72
 
43
## End: