I want to be able to take a dynamically created string, say “Pigeon” and determine at runtime whether Google App Engine has a Model class defined in this project named “Pigeon”. If “Pigeon” is the name of a existant model class, I would like to then get a reference to the Pigeon class so defined.
Also, I don’t want to use eval at all, since the dynamic string “Pigeon” in this case, comes from outside.
There’s two fairly easy ways to do this without relying on internal details:
Use the google.appengine.api.datastore API, like so:
The other option is to use the db.Expando class:
The latter has the advantage that you can use GetEntityClass to generate an Expando class for any entity type, and interact with it the same way you would a normal class.