Hi,
 I am trying to implement a data entry form for an entity called Model.
It should have a drop down menu showing entries from linked table pollutans.
So far no problem in implementing it. I want now to reorder the elements in
the dropdown menu using the field pollutant_order' in the pollutants_info 
table.
pollutants_info table has a 1:1 link to the pollutants table and is used to 
store
values that do not belong to the business data model.

I tried modifying the 

db.models.pollutant_fk.requires = 
IS_IN_DB(db,'pollutants.pollutant_id','%(pollutant_label)s')

using a query
qry=db(db.pollutants.pollutant_id ==  
db.pollutants_info.pollutant_id).select(orderby=db.pollutants_info.pollutant_order)

db.models.pollutant_fk.requires = 
IS_IN_DB(qry,'pollutants.pollutant_id','%(pollutants.pollutant_label)s')
but I get an exception

type 'exceptions.AttributeError'> 'Table' object has no attribute 
'pollutants.pollutant_label'
I think there is concept in the DAL that baffles me!



*Model *db.define_table('pollutant', 

   Field('pollutant_id', type='string'),

   Field('pollutant_notation', type='string'),

   Field('pollutant_label', type='string'),

   Field('pollutant_definition', type='string'),

   primarykey=['pollutant_id'],

   format='%(pollutant_definition)s',

   migrate=False)


db.define_table('pollutants_info',

   Field('pollutant_id', type='string'),

   Field('pollutant_order', type='integer'),

   Field('required_a', type='boolean'),

   Field('required_b', type='boolean'),

   primarykey=['pollutant_id'],

   format='%(pollutant_order)s',

   migrate=False)


db.define_table('models',
    Field('model_id', type='integer'),
    Field('model_code', type='string'),
    Field('pollutant_fk','reference pollutants.pollutant_id', represent= 
lambda id, row: db.pollutants(id).pollutant_label if id else ''),
    format='%(model_code)s',
    primarykey = ['model_id'],
    migrate=False)

db.models.pollutant_fk.requires = 
IS_IN_DB(db,'pollutants.pollutant_id','%(pollutant_label)s')

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to