Sunday, 15 September 2013

google app engine - Get datastore entity's parent key -



google app engine - Get datastore entity's parent key -

i trying parent key entity. have 2 classes, album , photo. album parent photo, when upload photo assign key of album belongs parent photo.

album = db.get(self.album_key) photo = photo(parent=album)

problem arises when seek query parent id photo. below code gives me output of "parent key: <"

photo = db.get(photo_key) photoparent = photo.parent self.response.out.write("parent key: %s" %photoparent)

how can pull parent key photo instance?

thanks!

parent method call, not property.

so code should read

photoparent = photo.parent()

see docs https://developers.google.com/appengine/docs/python/datastore/modelclass#model_parent

also when key output in

self.response.out.write("parent key: %s" %photoparent)

the keys str method outputs representation of object <>'s may want parent create it's html output more sane ;-)

cheers

tim

google-app-engine gae-datastore

No comments:

Post a Comment