I've done a parent - to - many child GAE / web2py implementation using
SelfReference  fields (or you can use Reference as well) using the
technique for adding native GAE fields into a web2py table definition.

It gives fantastic retrieval performance because GAE automatically
adds the link from the child back into the parent's reference list
at the time you create each child.   When you later query for the
parent, voila GAE retrieves all the child entities along with it in
one backend call!

Hopefully this technique is relevant to your application.

I also develop some other tricks for inheriting native GAE classes
into your web2py model, though
this is less attractive perhaps now that GAE native properties can be
directly declared in web2py tables.

- Dave Lypka.

On Jun 21, 10:25 am, Carles Gonzalez <carle...@gmail.com> wrote:
> Hi,
>
> I have developed some applications in web2py, and 2 are running
> currently in gae, but now i have serious problem.
>
> My current project is a social application, and when i design
> (example) the tables to make an user follow the actions other user
> (twitter like) I find that many-to-many relationships in app-engine
> are not easily supported.
>
> From my understanding using the tools present in web2py right i would
> need to do a lot of processing in memory, an that would hurt
> performance greatly.
>
> The pattern proposed by app store developers uses lists and "parent"
> relationship:
>
> class Message(db.Model):
>     sender = db.StringProperty()
>     body = db.TextProperty()
>
> class MessageIndex(db.Model):
>     receivers = db.StringListProperty()
>
> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', user_id)
> keys = [k.parent() for k in indexes)
> messages = db.get(keys)
>
> For using that pattern in web2py I would need a method for specifying
> the parent of a model instance. Can I specify that relationship using
> any method I don't know? If not, would it be hard to implement?
>
> Thanks in advance!

Reply via email to