On Saturday, August 2, 2008 11:26:12 AM UTC-7, Rein Petersen wrote:
>
> Thanks for the advice but I remain skeptical - I prefer that the 
> entities are stored in separate groups for speed's sake. If I want to 
> fetch Continents (there are only 7), I don't want to search an entity 
> group that includes 100's of 1000's of cities, regions, and 
> countries...


Datastore queries are designed to scale with the number of results, not the 
number entities. It shouldn't matter that your 100s of countries are mixed 
with 10000s of cities. If you find that it does, report it.

Having said that, putting continents into Datastore may be going for too 
much purity and/or elegance. Geological shifts happen slowly enough that 
your app (and the rest of civilization?) probably won't be around by the 
time South America and Africa reunite, or California sucedes from North 
America.
 

> Also, I do expect to uniquely extend the subclasses with 
> properties - I just don't know what they are yet... I'm still 
> designing. 
>
> Calvin, I'm curious why this is frowned upon in Python. Can you tell 
> me why or where I can read more about it? I'm so accustomed 
> abstracting and normalizing "all the way" as good OO and db design, 
> but if this can be problematic in some instances with Python and/or 
> with the GAE datastore, I want to know - my purpose is to design for 
> performance and scalability on this platform and I am all ears on the 
> matter.
>

Your idea to model with subclasses sounds good to me. This seems to be 
something that PolyModel was designed for.
 

>
> Thanks again for all the advice :) 
> Rein 
>
> On Aug 1, 3:43 pm, Blixt <[email protected]> wrote: 
> > I agree. Something like: 
> > class Area(db.Model): 
> >   CONTINENT = 1 
> >   COUNTRY = 2 
> >   REGION = 3 
> >   CITY = 4 
> > 
> >   name = db.StringProperty() 
> >   geo = db.GeoPtProperty() 
> >   level = db.IntegerProperty(choices = [Area.CONTINENT, Area.COUNTRY, 
> > Area.REGION, Area.CITY]) 
> > 
> > On Aug 1, 7:25 pm, "Calvin Spealman" <[email protected]> wrote: 
> > 
> > > Usually this kind of dependence on type is frowned upon in Python. If 
> > > the only difference between classes is the name, and otherwise they 
> > > are completely identical: the name should be the same too. I've never 
> > > seen a good reason to do this, and I've seen dozens of people with 
> > > cases where they thought it was a good idea. Another design has always 
> > > prevailed. 
> > 
> > > Are these all not simply "places"? Why not add a CategoryProperty? 
> > 
> > > On Fri, Aug 1, 2008 at 10:05 AM, 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 
> > 
> > > -- 
> > > Read my blog! I depend on your acceptance of my opinion! I am 
> interesting!http://ironfroggy-code.blogspot.com/

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