On Thu, Aug 13, 2009 at 6:44 PM, Dan V. <daniel.venkitacha...@gmail.com>wrote:
> > I'm experiencing some unexpected behaviour. > > In my code Category is derived from BaseModel and has a reference to > another entity (creator). If I initialize categories with a parent I > can trigger the error. > > (from a django shell session) > > a = Category('A', creator=my_guy) > a.save() > assert(Category.get_by_id(a.key().id())) # OK, no parent > > b = Category(parent=my_guy, 'B', creator=my_guy) > b.save() > assert(b.key().id()) # OK, key exists > assert(Category.get(b.key())) # OK as well > assert(Category.get_by_id(b.key().id())) # raises AssertionError > > So even though the key appears to be valid and have a numeric > identifier it cannot be used with get_by_id without throwing. Have I > missed something here? You need to pass the parent in with the get_by_id call so it can generate the proper key. http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_id -- Matt McDonald --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---