Hi,


I have several tables connected in the following way:


db.define_table('table_1',

    Field('name',unique=True))


db.define_table('table_2',

    Field(....),

    .....

    Field('ref_t1','reference 
table_1',requires=IS_IN_DB(db,db.table_1.id,'%(name)s')))


db.define_table('table_3',

    Field(....),

    .....

    Field('ref_t2','reference table_2',requires=IS_IN_DB(db,db.table_2.id)))


db.define_table('table_4',

    Field(....),

    .....

    Field('ref_t2','reference table_2',requires=IS_IN_DB(db,db.table_2.id)))



Ignoring for the moment the connection with table_1, I would like to add in 
the view for table_2 a direct link to edit table_3 (every grid row of 
table_2 as a 1-to-1 connection with a single instance of table_3 or 4).


Using grid I'm trying to set a link this way:


grid=SQLFORM.grid(db.table_2,.....,links = [lambda row: A ('modify', 
_href=URL('index', args=['edit','table_3', 
*db(db.table_3.ref_t2==row.id).select(db.table_3.id).first().id*
],user_signature=True),_class="btn")])


but it is not working and I can't understand why, since if I substitute 
"row.id" hardcoding the id of the row in the grid, it is working (clearly 
only for one row).

The error is:  *<type 'exceptions.AttributeError'> 'NoneType' object has no 
attribute 'id'*


An other option might be to change the link that display the children list 
in smartgrid to point directly to the edit page for the only child, but I'm 
not sure how to do it.


Any suggestion on how to solve this?


Thanks.



-- 
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