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.
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.