i have not used polymodels so i can't answer the last question.....but 
about that last one, when you access the GAE datastore viewer (as provided 
by GAE), what is the name of the table/model that is stored there?  does it 
store location_indoor  and location_outdoor, or just location with optional 
fields?  (i'd personally expect the former, but your experience sounds like 
the latter).

for your other questions see the example under this heading 
http://web2py.com/books/default/chapter/29/07?search=grid#SQLFORM.grid-and-SQLFORM.smartgrid
 
a few paragraphs in it shows a controller that can handle any table.

cfh

On Thursday, November 29, 2012 6:41:40 AM UTC-8, Gian Luca Decurtins wrote:
>
> Hi all
>
> Given the following model (polymodel location -> location_outdoor & 
> location_indoor) on GAE:
>
> define_table('location',
>     Field('name', 'string'),
>     Field('active', 'boolean'),
>     polymodel = True)
>
> define_table('location_outdoor',
>     db.location,
>     Field('country', 'string'),
>     Field('city', 'string'),
>     Field('postcode', 'string'),
>     Field('street', 'string'),
>     Field('building', 'string'),
>     polymodel = db.location)
>
> define_table('location_indoor',
>     db.location
>     Field('location_outdoor', db.location_outdoor),
>     Field('floor', 'string'),
>     Field('room', 'string'),
>     polymodel = db.location)
>
> - Is there a way to create a generic controller (using SQLFORM.grid) which 
> is able to create outdoor or indoor locations (display either 
> location_outdoor or location_indoor fields)?
> I'm thinking of a select field where I can select the class. Depending on 
> the class it will show the available fields.
> I should be able to modify the SQLFORM.grid to get view and edit 
> operations to use the correct class. But what about the create operation?
>
> - How can I add an extra field to the SQLFORM.grid view form which 
> displays the location? I would like to add a field which does contain a 
> generated QR-code.
>
> - Why are the indexes in index.yaml always called "location" and not 
> "location_outdoor" and "location_indoor"? I'm often receiving the error 
> message that location_indoor does not contain 'city', which is true.
>
> Cheers
> -Luca.
>

-- 



Reply via email to