I have a simple inheritance hierarchy of classes of objects that I
have stored in my datastore. I wish to fetch these objects from the
datastore using get_by_id(), and this works fine if I know the exact
class of the object that I am about to fetch. However, I would like to
be able to fetch using a parent class, and be able to get object of
any subclass. Unfortunately, the datastore does not seem to know about
the class inheritance of these objects.
For example:
class Entry(db.Model):
title = db.StringProperty(required=True)
class BinaryEntry(Entry):
content = db.BlobProperty(required=True)
class TextEntry(Entry):
content = db.TextProperty(required=True)
If I have a TextEntry in the datastore with an id of 1, this works:
entry = TextEntry.get_by_id(1)
but this does not:
entry = Entry.get_by_id(1)
Is there any simple way, without using the Expando model, that I can
do this? Note that I do not have the Key of the object I wish to
fetch, only the ID, and since I would need the Kind in order to create
the Key from the ID with db.Key.from_path(), I can't do a generic
db.get(key) either.
Thanks for any help,
Craig
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---