I think this is a clearer example to understand entities, key paths
and ancestors.
from google.appengine.api import users
from google.appengine.ext import db
class Parent(db.Model):
pass
class Child(db.Model):
data = db.IntegerProperty(default=0)
user = users.get_current_user()
parent_key_name = user.nickname()
child_key_name = 'child'
parent = Parent(key_name=parent_key_name)
# If we didn't pass key_name the key would not be created until .put()
and the next statement will fail
child = Child(parent=parent, data=55, key_name=child_key_name)
db.put([parent,child])
print child.data
parent_key = db.Key.from_path('Parent', user.nickname())
child = Child.get_by_key_name(child_key_name, parent=parent_key)
print child.data
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---