While GAE application code may use subclasses, the GAE datastore does not have any knowledge of the relationship between different entity types.
You can encode the class name/kind in your key name and then use db.class_for_kind to get the class. However, db.class_for_kind is not part of the documented API at this time. If you use it, you may want to request that it be documented (so it is more likely to continue to exist/work) by starring http://code.google.com/p/googleappengine/issues/detail?id=800&can=4&colspec=ID%20Type%20Status%20Priority%20Stars%20Owner%20Summary%20Log%20Component . Note that GAE keys know their kind. On Dec 10, 12:56 am, theillustratedlife <[EMAIL PROTECTED]> wrote: > I'm a Flash designer building an app in AppEngine. My knowledge of OO > principles is based on my experiences in Flash. > > Consider the following from models.py: > > class Question(BaseModel): > prompt = db.StringProperty(required = True) > > class ShortAnswerQuestion(Question): > multiline = db.BooleanProperty(default = True) > > class MultipleChoiceQuestion(Question): > choices = db.ListProperty(str) > > The properties that apply to all questions are in Question, with > subclasses to describe unique cases. Now if I know the key name of a > question, I ought to be able to do this: > > question = Question.get_by_key_name('question1') > > However, that doesn't work. question has been set to None. To get > the expected behavior, I have to use the particular subclass, like so: > > question = ShortAnswerQuestion.get_by_key_name('question1') > > For obvious reasons, I don't know what subclass the elements I'm > looking for are - I only know the key_name and that they descend from > the superclass Question. What is the correct way to convert a > key_name into an object in this situation? > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
