I tested this, and it does give all contacts when using
> contacts = db(db.contact.id>0).select()

Unfortunately, using
> person = db(db.person.id>0).select()

also returns all the contacts.  I think the intended behavior is to
just return the contacts that are also a person (as well as those that
are a sub-class of person.)  Additionally, trying to get at the person-
specific fields fails in that case, e.g.:
> for contact in person
>    response.flash= contact.first_name
doesn't work.

Also, the syntax is great for supporting polymodel, but if you want to
later add support for expando classes, it might be a bit awkward.

~Dave

On Sep 4, 10:34 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Can you help testing polymodel? In trunk:
>
> db=DAL('gae')
> db.define_table('contact',Field('address'), polymodel=True)
> db.define_table('person',Field('first_name'), polymodel=db.contact)
> db.define_table('company',Field('business_name'),
> polymodel=db.contact)
>
> db.person.insert(first_name="John", address="here')
> db.company.insert(business_name="John Inc", address="there')
> contacts = db(db.contact.id>0).select() # should lists both persons
> and conpanies
>
> Massimo
>
> On Sep 2, 11:07 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
>
>
> > I agree that polymodel would be trivial. We would only need to decide
> > how to pass parameters to db.define_table to determine if a table is a
> > polymodel or extends an existing one. This would not have an
> > equivalent in SQL.
>
> > On Sep 2, 10:40 am, Dave <thefe...@gmail.com> wrote:
>
> > > I'm new to Web2py and trying to get a sense for its GAE support,
> > > beyond the basic "RDBMS-like" functions (which Web2py seems to support
> > > very well!)
>
> > > Expando models and PolyModel:  Is there any way to use either of these
> > > with the DAL currently?  Are there plans to, if not?  PolyModel
> > > especially seems like it wouldn't be too difficult to add, as it can
> > > be used identically to the default Model class (all of its magic is
> > > handled under the hood I think.)
>
> > > Thanks for the information, and the great work so far.  I'm really
> > > impressed with how easy web2py is to develop with.

Reply via email to