The following are two approaches to the problem of handling data at arbitrary levels of specificity. Both handle the problem of Quotas and limits, but only one is easy to read through. Obviously, I chose the one with lower developer maintenance costs: PolyModel. View GitHub Gist.

instead of dropping all None columns from existence on database put via a hack, one can be smart about instantiating entities at the appropriate specificity and reap the rewards of inheritance


In Effective PolyModel, Rafe Kaplan uses the tried and true ecommerce catalog example for illustrating the benefits of using PolyModel.

Instead of placing all products in to a single class, it is possible to define each category as its own class that fits naturally in to a product category hierarchy.

Do your team a favor and check out google.appengine.ext.ndb.polymodel.PolyModel:

  1. Querying at arbitrary inheritence levels.
  2. Built in caching.
  3. One of the closest things you get to an SQL JOIN in App Engine.
  4. Easy to read data modeling.

182 words. Post tags: database, model, Google App Engine, PolyModel, and python.

Post content is written by Jason Zerbe and licensed CC BY-NC 3.0.