Solved!

The problem was ignoring the connection with table_1: table_3 and 4 names 
are equal to the db.table_1.name values.

The following code is working. 

The only things I don't understand is why it is necessary to use the "try:" 
syntax.
Without it, even though the link is correctly created and returned, the 
line "test= ... " is creating an error.

Can someone explain me why?

Thanks!

Nicola

def index():

    grid=SQLFORM.grid(db.table_2, create=False, editable=True, searchable=
False, details= True, csv=False,links=[lambda row: getLink(row)])
    return locals()


def getLink(row):
    try:
        test=db(db.table_1.id==row.ref_t1).select(db.table_1.name).first().
name
    except:
        link=''
    else:
        if test =='table_3':
            tb=db.table_3
        else:
            tb=db.table_4
        ID=db(tb.ref_tb2==row.id).select(tb.id).first().id

        link= A('modify',_href=URL('index',args=['edit',test,ID],
user_signature=True),_class='btn btn-default')


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