I have two tables, let's call them pages and revisions. Every page has many
revisions, so every revision contains the page as a foreign key. The page
has also one special revision which is the "live" one. I am doing (cutting
out the unnecessary code):
db.define_table('page',
Field('live_revision', db.revision),
)
db.define_table('revision',
Field('page', db.page),
)
Now, the first reference to db.revision before the table is created raises
an error. In Django, this is solved by quoting the relation name, as in
'db.revision'.
Is there a way to solve this in web2py?
I could of course create a
Field('live_revision_id', 'integer')
but I see two problems with it: first, I lose the automatic way of doing
e.g. page.live_revision.author to refer to the revision author, and second,
I don't think that there is an universal guarantee that auto-generated row
ids are integers (are they integers also in GAE?).
This must be an issue that comes up often; what's the solution?