From: Tobias W. <to...@gm...> - 2009-09-06 07:54:56
|
Hi, as I understand the documentation, sub-sub-classing InheritableSQLObject should be fine. But it messes with introspection, as demonstrated by the short attached script. When there is no C and you create and retrieve B, everything works. Introduce C, and running it with an empty database (rm /tmp/x) still works: <class '__main__.A'> <class '__main__.B'> X <class '__main__.C'> X But run it again, so that the first list() actually does retrieve something, and it will raise: <class '__main__.A'> <class '__main__.B'> X <class '__main__.C'> Traceback (most recent call last): File "desperate.py", line 23, in <module> list(B.select()) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/SQLObject-0.12dev_r3970-py2.6.egg/ sqlobject/sresults.py", line 179, in __iter__ return iter(list(self.lazyIter())) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/SQLObject-0.12dev_r3970-py2.6.egg/ sqlobject/inheritance/iteration.py", line 43, in next childResults=childResults, connection=self.dbconn) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/SQLObject-0.12dev_r3970-py2.6.egg/ sqlobject/inheritance/__init__.py", line 309, in get selectResults=childResults) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/SQLObject-0.12dev_r3970-py2.6.egg/ sqlobject/inheritance/__init__.py", line 309, in get selectResults=childResults) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/SQLObject-0.12dev_r3970-py2.6.egg/ sqlobject/inheritance/__init__.py", line 290, in get val = super(InheritableSQLObject, cls).get(id, connection, selectResults) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/ lib/python2.6/site-packages/SQLObject-0.12dev_r3970-py2.6.egg/ sqlobject/main.py", line 893, in get val._init(id, connection, selectResults) File "/Users/towb/Desktop/desperate.py", line 10, in _init print getattr(self, 'name') File "<string>", line 1, in <lambda> AttributeError: 'NoneType' object has no attribute 'name' I couldn't find out what actually happens as the code is full of eval()... |