Relaionships on GAE

4 views
Skip to first unread message

yamandu

unread,
Jan 4, 2010, 10:57:48 PM1/4/10
to web2py-users
Google people recommend to use list properties to do many to many
relationships.
Since now, all GAE types are supported, I ask:
Is or will be this supported in web2py? Or one must code it manually?
Someone has a tip to design relationships in web2py on gae?

I´ve been coding in web2py on GAE but sometimes things get hard and I
have spend more time thinking a new way to do old things.

mdipierro

unread,
Jan 5, 2010, 9:24:16 AM1/5/10
to web2py-users
You can do things like

db.define_table('person',Field('name'),
Field('friends',gae.ListProperty(int),readable=False,writable=False))

now you can do:

tim=db.person.insert(name='Tim',friends=[])
kim=db.person.insert(name='Kim',friends=[tim])

friends_of_tim=db(db.person.friends==tim).select()

Mind that this would only work on GAE and the "friends" field would
not show up in forms.

yamandu

unread,
Jan 5, 2010, 4:05:24 PM1/5/10
to web2py-users
Thanks again for the examples Massimo.
They help a lot.
Reply all
Reply to author
Forward
0 new messages