HI I have been down this path and I ended up using to property lists
one being a list of keys to children and the second a list of object names, (that way I can traverse the tree by entity names). and each object keeps a referenceproperty to it's parent. That way if I get some arbitrary object I can walk back up the tree. I didn't use a back ref (ie parent.children.all()) as a result of the parent reference as it will be segmented by kind. Which means you have to have multiple reference_sets (one for each kind). (Unless you use polymodels) I also abandoned any notion of using the key path because if a node changes the key path is set so you need to create a whole new entity and it's children. There are a couple of advantages to the approach I have used. 1, moving nodes around isn't expensive (ie remove name and key from one list an put it in another) all the nodes children don't need to be touched. 2. A node can be a child of multiple entities (though you would then need to abandon the parent reference held by a child) 3. explicit ordering of children doesn't require touching children. The downside of this approach is you can't really use transactions/ entity groups as (well you can but everything will be in a single entity group which sort of defeats the point of entity groups. So it is really only usefull of the you are unlikely to have concurrent mutating of the tree. I am using this in a simple cms based on repoze.bfg which provides folder based organisation and traversal of various content types such as pages, news, images, files, galleries etc... (www.fishandlily.com.au is a site based on this cms) I will be releasing the code for it as soon as I clean it up an document it a bit. See ya T On Jul 13, 3:31 am, Peter Cicman <[email protected]> wrote: > I had spend some time today with building tree structure using > datastore. I need a real tree, for real world, so there must be a > possibility to move node with all descendants. There must also be a > quick way to find all ancestors, children and descendants. > > So, datastore keys can not be used for tree like this - because key > can not change, and i would like to prevent node copying/deletion, > because this must be always done on node and all its descendants which > may end up with tons of sql queries. > > Design i made should fit for me, but maybe there is some common > solution for this problem... Anybody knows about some optimal > solution? (i can not use serialization) > > Thanks a lot! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" 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/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
