[google-appengine] Re: Modeling mutual references

2008-10-17 Thread Dado
That's not the point ;) discussed here... indeed the Book model (see below) do get a pages_set including all pages of that book, the problem discussed here is that the Book model can't declare the first property because it references the Page model which is not yet loaded by the interpreter.

[google-appengine] Re: Modeling mutual references

2008-10-16 Thread Dado
Let's say it can't be elegantly solved! ;) On Oct 15, 9:46 pm, Andy Freeman [EMAIL PROTECTED] wrote: as yejun wrote up at the top, the following works, but doesn't verify that assignments to Book().first are instances of Page. class Book(db.Model):         title = db.StringProperty()      

[google-appengine] Re: Modeling mutual references

2008-10-16 Thread Sudhir
If you add a reference to one model from the other, the other model automatically gets a back reference... class Point(db.Model): Store the map points point = db.GeoPtProperty(required = True) title = db.StringProperty(required = False) owner =

[google-appengine] Re: Modeling mutual references

2008-10-15 Thread kang
Maybe: class Book(db.Model): title = db.StringProperty() first = db.ReferenceProperty(Page) class Page(db.Model): text = db.TextProperty() next = db.SelfReferenceProperty() book =

[google-appengine] Re: Modeling mutual references

2008-10-15 Thread Andy Freeman
Using multiple files for dbModel subclass definitions during development runs into the GAE/python doesn't reload what hasn't changed problem. If db.Model A is defined in fileA, db.Model B is defined in fileB and B has a db.ReferenceProperty to A, B's definition will generate errors when you

[google-appengine] Re: Modeling mutual references

2008-10-15 Thread Andy Freeman
The problem really has nothing to do with how import works. It's an execution order problem. Short version: yes, the problem is that Page doesn't exist when Book is defined. However, it has nothing to do with imports. Long version: Import reads and executes statements from a file and makes

[google-appengine] Re: Modeling mutual references

2008-10-14 Thread Dado
I am having the same problem when defining a join model between two models... because they depend on each other, but in my case is a problem related to how Python imports classes (I am using import to pull in models definitions that are in different files). Does the code that you posted all

[google-appengine] Re: Modeling mutual references

2008-10-09 Thread yejun
You don't have to give class for ReferenceProperty. first = db.ReferenceProperty() On Oct 9, 6:53 pm, acuth [EMAIL PROTECTED] wrote: Is it possible to have two models reference each other? I can't get this to work and haven't been able to find this limitation in the documentation. As a simple