[SQLObject] Re: SQLObject inheritance patch 2
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Daniel S. <sa...@gn...> - 2004-02-12 03:38:45
|
Hello Oleg, I tried your test with MySQL and PostGreSQL under Python 2.2.3 and 2.3.3 and it worked well. What database are you using ? Did you create the table (createTable method) ? You should add theses two lines after class creation: Woman.createTable(1) Wilma.createTable(1) I tried your sample without creating the table and get the same problem as your. Adding theses two lines just after the class creation corrected it. Daniel Savard Oleg Broytmann wrote: >Hi! > > I tried a simplest test. > >import SQLObject >from db import db_conn > > >class Woman(SQLObject.SQLObject): > _inheritable = 1 > _connection = db_conn > > name = SQLObject.StringCol() > > >class Wilma(Woman): > smile = SQLObject.IntCol() > > >wilma = Wilma.new(name="Wilma", smile=1) >barney = Barney.new(passion=wilma) > >woman = Woman(1) >print woman # prints <Wilma 1 childName=None smile=1>, ok >print woman.smile # => 1 >print woman.name > >Traceback (most recent call last): > File "test.py", line 10, in ? > print woman.name > File "<string>", line 1, in <lambda> >AttributeError: 'Wilma' object has no attribute '_parent' > > Oops. I found many places in the code where _parent attribute is >used, but only one where it is assigned - in new(). Shouldn't it be >assigned in __new__ too? > >Oleg. > > |