Appengine Model SelfReferenceProperty and parent child relationship

Posted by GeekTantra on Stack Overflow See other posts from Stack Overflow or by GeekTantra
Published on 2010-06-13T05:43:53Z Indexed on 2010/06/13 5:52 UTC
Read the original article Hit count: 213

Filed under:
|

I have a scenario in which I need a self reference property as follow:

class Post(db.Model):
  creator = db.UserProperty()
  post_title = db.StringProperty(required=True)
  post_status = db.StringProperty(required=True, choices=['draft', 'published'])
  post_parent = db.SelfReferenceProperty()

Now, I want ensure that an entity shouldn't be its own parent and a child of an entity cannot be its parent. How can I ensure this kind of a relationship in the PostForm model form and the Post model.

© Stack Overflow or respective owner

Related posts about python

Related posts about google-app-engine