Samnsparky/Sirpple — Issue #11: GAE Model.get_by_id() requires the direct parent to work
Author: djsutton
Created: 2011-12-22 09:05:32+00:00
State: open
Labels: High Priority

A close reading of the docs at http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_id shows that the parent keyword arg is *required* if the model we are looking for has a parent. I think we had been asuming that an ID alone was enough to uniquely retrieve a model. This is a problem for us because it essentially means we need to know all the ancestors of a model to retrieve it. For example, to retrieve a WorldSubscription by ID, we need to know the parent WorldMethod, to retrieve the WorldMethod by ID, we need to know the parent World, to retrieve the parent World By ID, we need to know the ID of the parent Project, etc. I think this is too many database lookups and too many IDs to carry around.

We may be able to use something like key names from http://code.google.com/appengine/docs/python/datastore/entities.html to generate short identifiers on a per project basis, and then we would only need to know the project. No matter how we solve this, it seems it will involve making another function that works like get_by_id(). Perhaps this could be hidden in GAEAdaptedModel? I plan to investigate this further sometime soon.