Hi guys,

Thanks for the suggestions!  However, there is a slight detail that I
forgot to mention.  I need to be able to dynamically define the
subcategories, and I have literally hundreds of them already defined
(more to be added by users).  Storing the categories as a
StringListProperty seems promising.  That means that when I'm writing
an entity to the datastore with a specific supercategory, I have to
look for all subcategories and add those to the list as well.  Can you
guys suggest a schema that won't require an extra call to the database
by storing the relationships within the schema?

Thanks!

On Jul 19, 2:20 am, gops <[email protected]> wrote:
> you can achieve this in polymodel by adding all common properties to
> polymodel base class and specific property to the hierarchy.
>
> i.e.
>
> Class LivingThing(polymodel.PolyModel):
>     Kingdom = db.StringProperty()
>     Phylum = db.StringProperty()
>     Subphylum = db.StringProperty()
>
> Class Mammal(LivingThing):
>     noofbreast = db.IntegerProperty()
>
> class Monkey(Mammal):
>    canjump = db.BooleanProperty()
>
> now you can create class monkey as,
> Monkey(Kingdom="Animal",canjump=True)
>
> and later query as LivingThing.filter("Kingdom =","Animal").fetch()
>
> can return Monkey.
>
> On Jul 19, 1:04 pm, Bill Edwards <[email protected]> wrote:
>
> > Hi!
>
> > I've been recently trying to wrap my head around GAE's datatypes.  Is
> > there a model type in GAE that allows me to define subproperties?  For
> > example, I want to have a "category" property where some categories
> > fall under others, and when i query for all entities within a
> > supercategory, i get the subcategories also.
>
> > For example:
> > class Animals(db.Model):
> >     type = db.StringProperty()
>
> > Animals(type='mammal')
> > Animals(type='chimpanzee')
> > Animals(type='monkey')
>
> > When I query for all animals with type mammal, i want to return all 3
> > of the above objects.
>
> > I've read through the documentation, and the PolyModel datastore model
> > has struck my eye as being potentially helpful.  However, it doesn't
> > seem to quite do the job.
>
> > 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.

Reply via email to