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
-~----------~----~----~----~------~----~------~--~---