Assumptions: 1) Google AppEngine has the concept of Entity Groups. 2) Entities in an entity group form a tree. However, as far as I understood, every put() to any entity in that tree will lock the whole tree (not just the immediate parent) for a while. 3) Users are allowed to write ca. 5 times per seco开发者_开发问答nds to the tree. 4) There is no way to have a non-locking behaviour (i.e. by making them unindexed properties)
Would it be a smart idea to come up with my own parent-child model that does not use the built-in Key-functions (as those would create entity groups) but instead use some snytax convetions that I made up? This would allow me to retrieve a "child" entity via a query an compute the parent key.
The ancestor relationship used by entity groups can be modeled in your own code by using a list of references/keys to parent entities. Root entities will have none, children of roots will have just the root entity in their list, their children will have the root and their immediate parent, and so forth. This is how ancestors are implemented in App Engine for indexing purposes, and it'll permit you to make the same sorts of queries.
You can use a reference property:
class Parent(db.Model):
x = db.IntegerProperty()
class Child(db.Model):
parent = db.ReferenceProperty(
reference_class = Parent,
collection_name = 'children')
y = db.IntegerProperty()
精彩评论