There is PolyModel, which will return subclass instances when queried. Not 
sure if that existed at the time, but it sounds like exactly what you are 
looking for. e.g.

from google.appengine.db import polymodel  # ndb also has this

class P(polymodel.PolyModel): pass
class C1(P): pass
class C2(P): pass

P.all()  # May return instances of C1 and/or C2.


On Friday, August 1, 2008 7:30:28 AM UTC-7, Rein Petersen wrote:
>
> Andreas, thanks for that :) 
> I'll be relating the entities using parent-child relationships. It is 
> unfortunate that you cannot query a base model and find the subclasses 
> - oh well, don't want to throw the baby out with the bathwater... 
> Thanks again, 
> Rein 
>
> On Aug 1, 9:09 am, Blixt <[email protected]> wrote: 
> > You use the 'pass' keyword in Python to skip an implementation: 
> > class Region(Place): 
> >   pass 
> > 
> > Also worth noting is that data-wise, those models will have no 
> > relation to eachother in the datastore, so you can only query for one 
> > type at a time. Just in case you didn't consider it, might save you 
> > some time :) 
> > 
> > Regards, 
> > Andreas 
> > 
> > On Aug 1, 4:05 pm, Rein Petersen <[email protected]> wrote: 
> > 
> > > Hi All, 
> > 
> > > I'm using Model inheritance to distinguish distinguish entities that 
> > > are, essentially, the same. Usually, inheritance involves extending 
> > > the base class with more properties (and such) defined in the 
> > > subclasses but in my instance, extension is not required - only 
> > > distinction. An example is provided below. 
> > 
> > > The problem is that an exception is raised when there is no code below 
> > > the class definition: 
> > 
> > > <type 'exceptions.IndentationError'>: expected an indented block 
> > 
> > > I could easily give up using inheritance and define the properties on 
> > > each model separately, or I could continue with inheritance but pull 
> > > one property out of the base and repeat it in the subclasses but it 
> > > pains me to do so. 
> > 
> > > I was wondering if there were some little bit of insignificant I place 
> > > in the subclass definitions that would satisfy the interpreter to 
> > > avoid the IndentationError exception... Thanks Rein :) 
> > 
> > > *** Example :: models.py 
> > > class Place(db.Model): 
> > >   # abstract 
> > >   name = db.StringProperty() 
> > >   geo = db.GeoPtProperty() 
> > 
> > > class Continent(Place): 
> > >   # represents a continent 
> > 
> > > class Continent(Place): 
> > >   # represents a continent 
> > 
> > > class Country(Place): 
> > >   # represents a country 
> > 
> > > class Region(Place): 
> > >   # represents a region 
> > 
> > > class City(Place): 
> > >   # reprecents a city

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to