I've created a model in the GAE SQL tool - which was great, except it
didn't work in web2py. I just got errors.
So I created a model from the wizard to get going, but I've got some
strange behaviour around relationships.
I have a table 'labels' which is linked to a number of other tables.
A couple of these links work as you'd expect - in the edit screen you
see a drop list of the 'name' field from the relate table. For some
reason I can't fathom ONE of these tables ('winery') shows a text
field into which the ID of the related record has to be added. That
related table 'winery' is similar to the others that do work 'variety'
and 'retailcategory', and has a 'name' field with the same data type
as the others. These relationships are modelled:
Field('f_retailcategory', type='reference t_retailcategory',
label=T('Retailcategory')),
Field('f_winery', type='reference t_winery',
label=T('Winery')),
On searching the syntax is suggested as:
Field('f_winery_id', db.winery),
or
Field('f_winery_id', db.t_winery)
However adding these lines just causes it to blow up and show the
error:
<type 'exceptions.KeyError'> 'winery'
This is all a bit arcane. I can't understand why the GAE stuff
does'nt work after fixing all the parsing errors.
I've used PHP Cake a bit, so I get the concepts, but at this stage it
seems the documentation != practice.
Any tips?
thanks