Google App Engine : PolyModel + SelfReferenceProperty
- by rvandervort
Is a PolyModel-based class able to be used as a SelfReferenceProperty ?
I have the below code :
class BaseClass(polymodel.PolyModel):
attribute1 = db.IntegerProperty()
attribute2 = db.StringProperty()
class ParentClass(BaseClass):
attribute3 = db.StringProperty()
class ChildClass(BaseClass):
parent = SelfReferenceProperty(collection_name = 'children')
p = ParentClass()
p.attribute1 = 1
p.attribute2 = "Parent Description"
p.attribute3 = "Parent additional data"
p.put()
c = ChildClass()
c.attribute1 = 5
c.attribute2 = "Child Description"
c.parent = p.key()
c.put()
I execute this code and check the datastore via the development server's admin interface.
The parent instance is saved to the datastore class = 'BaseClass,ParentClass', but the child is not. There is no error output to the browser (debug is turned on) and nothing in the launcher's log for my app.
Is this possible to do ?