Hi Oliver, Great suggestion and I want to make sure I understand the proposal. It sounds like you would like the House model to have a parents back reference and also a children back reference? How would the children collection be given a collection name?
Here's some sample code to make this easier to follow: from google.appengine.ext import db from google.appengine.ext.db import polymodel class House(db.Model): address = db.IntegerProperty() class Parent(polymodel.PolyModel): house = db.ReferenceProperty(House, collection_name='parents') class Child(Parent): pass h1 = House(address=5).put() Parent(house=h1).put() Child(house=h1).put() Parent(house=h1).put() h1 = db.get(h1) h1.parents.fetch(5) With the above code, the h1 House instance has 3 entities in its parents back reference, 2 Parent instances and 1 Child instance. Instead you would like only the 2 Parent classes to appear in h1.parents? If that's the case, then you can do something like this instead: class Parent(polymodel.PolyModel): house = db.ReferenceProperty(House, collection_name='parents') class Child(Parent): home = db.ReferenceProperty(House, collection_name='children') h1 = House(address=5).put() Parent(house=h1).put() Child(home=h1).put() Parent(house=h1).put() h1 = db.get(h1) h1.parents.fetch(5) h1.children.fetch(5) I'm guessing the above would be OK if it is acceptable that the Child's reference to House is called 'home' instead of the parent classes 'house'. Thank you, Jeff On May 22, 11:19 am, Oliver Zheng <goo...@oliverzheng.com> wrote: > I'm trying to create a hierchy of kinds, the obvious reason of which > is that kinds can share model fields. However, for > ReferenceProperties, collection_name is fixed to when the model field > is declared in the model class. If this is declared in the parent > class, then all the children will have this collection name, which is > likely inaccurate: > > class Parent(PolyModel): > house = db.ReferenceProperty(House, collection_name='parents') > > class Child(Parent): > pass > > House won't have a back reference to children in particular. And since > for PolyModels, fields cannot be overriden by children classes, Child > can't have its own house field. > > This problem could be solved if collection_name was callable, so that > the children class could return its own collection name. Is there > plans for this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---