I was able to "solve" it with a kludge. I changed this _href=URL('get_approval', args=[row.opt.id], user_signature=True),
to this _href=URL('get_approval', args=[str(row).split("'id': ")[1].split(',')[0]], user_signature=True), and now everything works. But I still don't understand why the strange error. Any ideas? Thanks, JM quinta-feira, 28 de Março de 2019 às 12:41:23 UTC, João Matos escreveu: > > Hello, > > I have this grid > > # Hidden fields in grid and edit/view form. > db.opt.canceled_on.readable = False > db.opt.canceled_by.readable = False > db.opt.cancel_approved_by.readable = False > > query = ((db.opt.is_active == True) & (db.opt.opt_cat_id == db. > opt_cat.id)) > > grid = SQLFORM.grid( > query, > csv=False, > deletable=False, > details=False, > fields=[ > db.opt.id, > db.opt.name, > db.opt_cat.name, > db.opt_cat.name_en, > ], > headers={'opt_cat.name': T('Category'), 'opt_cat.name_en': T( > 'Category')}, > links=[ > lambda row: A( > SPAN(T('Delete'), _class='buttontext button', _title= > 'Delete'), > _href=URL('get_approval', args=[row.opt.id], > user_signature=True), > _class='button btn btn-default btn-secondary', > ), > ], > maxtextlength=GRID_COL_LEN_FOR_TEXT, > ondelete=on_delete, # Grid only. > onvalidation=on_validation, # Form only. > orderby=db.opt.name, > paginate=session.auth.user.pagination, > # represent_none='', # Grid and view form only. > ) > > If I select the Delete button (link) everything works as expected. > > If I select the auto-created Edit button, web2py returns this strange error > > ERROR:web2py:Traceback (most recent call last): > File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 107, in > __getattr__ > > return self.__getitem__(k) > File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 94, in > __getitem__ > raise KeyError(key) > KeyError: 'opt' > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "C:\web2py\gluon\restricted.py", line 219, in restricted > exec(ccode, environment) > File "c:\web2py\applications\ajc\controllers/opt.py", line 537, in > <module> > File "C:\web2py\gluon\globals.py", line 421, in <lambda> > self._caller = lambda f: f() > File "C:\web2py\gluon\tools.py", line 3868, in f > return action(*a, **b) > File "c:\web2py\applications\ajc\controllers/opt.py", line 245, in index > paginate=session.auth.user.pagination, > File "C:\web2py\gluon\sqlhtml.py", line 2583, in grid > res = DIV(buttons(view=details, record=record), > File "C:\web2py\gluon\sqlhtml.py", line 2505, in buttons > elif link(record): > File "c:\web2py\applications\ajc\controllers/opt.py", line 237, in > <lambda> > _href=URL('get_approval', args=[row.opt.id], user_signature=True), > File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 109, in > __getattr__ > > raise AttributeError > AttributeError > > > If I comment the links parameter, the edit works. > > Thanks, > > JM > > > > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.