HI cfh
You're right. As far as I can see in the datastore viewer there is only one
table. There is also a class value available.
I did try a few more things (resetting local datastore and removing the
entries in index.yaml) but I'm not able to access all three tables using
the following controller:
@auth.requires_signature()
def form():
table = request.args(0)
if not table in db.tables(): redirect(URL('error'))
db[table].id.readable = False
form = SQLFORM.grid(db[table],args=request.args[:1],
user_signature=True)
return dict(form=form)
When I do call
"http://localhost:8080/init/location/form/location_outdoor?_signature=xxx'
I receive:
AttributeError: 'location' object has no attribute 'country'
When I call
"http://localhost:8080/init/location/form/location_indoor?_signature=xxx' I
receive:
AttributeError: 'location_outdoor' object has no attribute
'location_outdoor'
Right after resetting the datastore I'm able to access 'location,
'location_outdoor' and 'location_indoor'. Once I create an indoor or
outdoor location I'm not able to access the other form anymore. The
'location' form is still available.
I'm trying to store all location information (outdoor / indoor) in one
polymodel. I do want to take advantage of having to have only one reference
between devices and locations.
Any suggestions?
Greetings
-Luca.
Am Donnerstag, 29. November 2012 19:27:03 UTC+1 schrieb howesc:
>
> 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.smartgrida
> 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.
>>
>
--