In Google App Engine, an entity has a Key. A key can be made from a path, in which case str(key) is an opaque hex string. Example:
from google.appengine.ext import db
foo = db.Key.from_path(u'foo', u'bar', _app=u'baz')
print foo
gives
agNiYXpyDAsSA2ZvbyIDYmFyDA
if you set up the right paths to run the code.
So, how can one take the hex string and get the path back? I thought the answer would be in Key or entity group docs, but I can't see it.
Once you have the
Key
object (which can be created by passing that opaque identifier to the constructor), useKey.to_path()
to get the path of aKey
as a list. For example:when run in a Development Console, this outputs:
as requested. A shorter alternative is to use the (unfortunately, I believe, undocumented)
to_path
method ofKey
instances:with the same results. But the first, longer version relies only on documented methods.