Sounds great! I'm on vacation this week, but I look forward to trying it out next week.
~Dave On Sep 12, 10:56 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > This is now fixed. Here is a final example of usage: > > db=DAL('gae') > db.define_table('contact',Field('address'), polymodel=True) > db.define_table('person',Field('first_name'), db.contact, > polymodel=db.contact) > db.define_table('company',Field('business_name'),db.contact,polymodel=db.co > ntact) > > if not db(db.contact.id>0).count(): > db.person.insert(first_name="John", address='here') > db.company.insert(business_name="John Inc", address='there') > > persons = db(db.person.id>0).select() > companies = db(db.company.id>0).select() > contacts = db(db.contact.id>0).select() > # latter includes both people and companies > > Mind that you can do: > > db.define_table('person',Field('first_name'), db.contact, > polymodel=db.contact) > > or > > db.define_table('person',db.contact, Field('first_name'), > polymodel=db.contact) > > I.e. you must choose explicitly whether the fields of the extended > class should appear after or before the new fields. > > On Sep 10, 3:27 pm, Dave <thefe...@gmail.com> wrote: > > > > > It still has both the original problems. Here's what I'm testing so > > far: > > > >contacts = db(db.contact.id>0).select() > > > Returns all contacts, as it should > > > >people = db(db.person.id>0).select() > > > Also returns all contacts, instead of just the contacts that are of > > type "person" > > > >address = people[0].address > > > Works, and returns the address of the first person. > > > >name = people[0].first_name > > > Crashes, with the following trace: > > > Traceback (most recent call last): > > File "C:\Users\Dave\Documents\Python\web2py\gluon\restricted.py", > > line 188, in restricted > > exec ccode in environment > > File "C:\Users\Dave\Documents\Python\web2py\applications\welcome/ > > controllers/default.py:index", line 66, in <module> > > File "C:\Users\Dave\Documents\Python\web2py\gluon\globals.py", line > > 96, in <lambda> > > self._caller = lambda f: f() > > File "C:\Users\Dave\Documents\Python\web2py\applications\welcome/ > > controllers/default.py:index", line 23, in index > > File "C:\Users\Dave\Documents\Python\web2py\gluon\sql.py", line 729, > > in __getattr__ > > return dict.__getitem__(self,key) > > KeyError: 'first_name'