Jon
Jon

Reputation: 794

Python Parent Child Relationships in Google App Engine Datastore

I am trying to model a parent hierarchy relationship in Google App Engine using Python. For example, I would like to model fruit.

So the root would be fruit, then a child of fruit would be vine-based, tree-based. Then for example children of tree-based would be apple, pear, banana, etc. Then as children of apple, I would like to add macintosh, golden delicious, granny smith, etc.

I am trying to figure out the easiest way to model this such that I can put in another entity of type basket a an entity of type fruit, or of type granny smith.

Any help would be greatly appreciated!

Thanks Jon

Upvotes: 0

Views: 314

Answers (1)

Nick Johnson
Nick Johnson

Reputation: 101139

What you're talking about is inheritance heirarchies, but App Engine keys provide for object heirarchies. An example of the former is "a banana is a fruit", while an example of the latter is "a car has a steering wheel". Parent properties are the wrong thing to use here; you want to use PolyModel.

Upvotes: 2

Related Questions