correct -- there currently is no "reference generic" (and integer is the way);
My question was: would it serve the community, be more obvious is there _was_ a "reference generic" so that these questions wouldn't need to come up.... On Sun, Sep 6, 2009 at 12:00 AM, mdipierro <[email protected]> wrote: > > Instead of 'reference generic' just use 'integer' and everything else > will work. > > On Sep 5, 10:27 pm, Yarko Tymciurak <[email protected]> wrote: > > On Sat, Sep 5, 2009 at 9:40 PM, Matthew <[email protected]> > wrote: > > > > > Does Web2py have any concept of Polymorphic Associations like Ruby or > > > Generic Relations like Django? > > > > I think this is simple - rather than declaring a Field as a db.table > (ergo a > > reference), or a forward "reference" to another table, you can simply > define > > the field as was done before the forward reference syntax - as an integer > > field. > > > > We could make a generic reference to affect this - perhaps it would be > > easier for people to remember, e.g.: > > > > db.table_define( 'mytable', > > # .... > > Field( 'myref', 'reference generic' ); # DAL doesn't have this; > > should it so that generic references are explicitly named? > > > > If this seems too simple, remember the DAL makes a default ID, and it is > > numeric and autoincrementing (there are no classes to deal with). > > > > No you can simple do something like > > > > for for in db(db.othertable.id == db.mytable.myref).select(): > > print row.value_of_interest > > > > So - there are your "Polymorphic Associations" or "Generic Relations" --- > > without the fancy names or complications - the ID is just an index - an > > integer, and uniformly so. > > > > - Yarko > > > > > > > > > This would be very beneficial for tagging or voting, because there is > > > usually a need to tag or vote on different models in the same > > > application. > > > > > Thanks, > > > Matthew > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

