Does your query/grid include the 'id' field? Did the same code used to work
on 1.99.2?
On Thursday, December 1, 2011 1:13:16 PM UTC-5, David Watson wrote:
>
> I am running web2py version 1.99.3
>
> I have the following code in my default controller. The view shows the
> item. When i run
> links = [lambda row:
> A('Edit',_href=URL("default","sweeps",args=[row.id])),
> lambda row:
> A('Delete',_href=URL("default","promos",args=[row.id]))]
> grid2 = SQLFORM.grid(db.auth_user, links=links)
> return dict(item=grid2)
>
> but it blows up with a keyerror on id. I thought my lambda links were
> correct, but maybe something has changed or I've gotten it wrong?
>
> Thanks,
> David
>
> <type 'exceptions.KeyError'> 'id'
>
> Traceback (most recent call last):
> File "/home/watson/latte/web2py/gluon/restricted.py", line 204, in
> restricted
> exec ccode in environment
> File "/home/watson/latte/web2py/applications/latte/controllers/
> default.py", line 139, in <module>
> File "/home/watson/latte/web2py/gluon/globals.py", line 162, in
> <lambda>
> self._caller = lambda f: f()
> File "/home/watson/latte/web2py/applications/latte/controllers/
> default.py", line 45, in apps
> (db.portal_keyword.user_id==auth.user_id), links=links,
> fields=fields, paginate=10, ui="jquery-ui")
> File "/home/watson/latte/web2py/gluon/sqlhtml.py", line 1810, in
> grid
> if link(row):
> File "/home/watson/latte/web2py/applications/latte/controllers/
> default.py", line 41, in <lambda>
> links = [lambda row:
> A('Edit',_href=URL("default","index",args=[row.id])),
> File "/home/watson/latte/web2py/gluon/dal.py", line 3948, in
> __getattr__
> return self[key]
> File "/home/watson/latte/web2py/gluon/dal.py", line 3939, in
> __getitem__
> return dict.__getitem__(self, key)
> KeyError: 'id'
>
>