Problem with .smartgrid on tables with links

151 views
Skip to first unread message

Jim Steil

unread,
Jan 19, 2012, 11:45:13 AM1/19/12
to web2py-users
Hi

Just updated to the latest trunk this morning and now my smartgrids aren't working where the table being used has links.

Here is what I'm getting:
Traceback (most recent call last):
  File "C:\dev\web2py\gluon\restricted.py", line 204, in restricted
    exec ccode in environment
  File "C:/dev/web2py/applications/infocenter/controllers/administration.py", line 1816, in <module>
  File "C:\dev\web2py\gluon\globals.py", line 172, in <lambda>
    self._caller = lambda f: f()
  File "C:\dev\web2py\gluon\tools.py", line 2530, in f
    return action(*a, **b)
  File "C:/dev/web2py/applications/infocenter/controllers/administration.py", line 457, in assetTypes
    paginate=15, maxtextlength=45)
  File "C:\dev\web2py\gluon\sqlhtml.py", line 1971, in smartgrid
    user_signature=user_signature,**kwargs)
  File "C:\dev\web2py\gluon\sqlhtml.py", line 1819, in grid
    if link(row):
  File "C:\dev\web2py\gluon\sqlhtml.py", line 1968, in <lambda>
    args=request.args[:nargs]+[args0,row.id])))
  File "C:\dev\web2py\gluon\dal.py", line 4996, in __getattr__
    return self[key]
  File "C:\dev\web2py\gluon\dal.py", line 4987, in __getitem__
    return dict.__getitem__(self, key)
KeyError: 'id'

If the table doesn't have any fields referencing other tables, then it works fine.

Is it just me?

    -Jim

Massimo Di Pierro

unread,
Jan 19, 2012, 12:34:41 PM1/19/12
to web2py-users
Do the tables have id fields called other than id?

On Jan 19, 10:45 am, Jim Steil <j...@qlf.com> wrote:
> Hi
>
> Just updated to the latest trunk this morning and now my smartgrids
> aren't working where the table being used has links.
>
> Here is what I'm getting:
>
> Traceback(most recent call last):
>    File"C:\dev\web2py\gluon\restricted.py",line204,inrestricted
>      execccodeinenvironment
>    File"C:/dev/web2py/applications/infocenter/controllers/administration.py"  <http://127.0.0.1:8000/admin/default/edit/infocenter/controllers/admin...>,line1816,in<module>
>    File"C:\dev\web2py\gluon\globals.py",line172,in<lambda>
>      self._caller=lambdaf:f()
>    File"C:\dev\web2py\gluon\tools.py",line2530,inf
>      returnaction(*a, **b)
>    File"C:/dev/web2py/applications/infocenter/controllers/administration.py"  <http://127.0.0.1:8000/admin/default/edit/infocenter/controllers/admin...>,line457,inassetTypes
>      paginate=15,maxtextlength=45)
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1971,insmartgrid
>      user_signature=user_signature,**kwargs)
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1819,ingrid
>      iflink(row):
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1968,in<lambda>

Jim Steil

unread,
Jan 19, 2012, 1:58:06 PM1/19/12
to web...@googlegroups.com
Yes, my tables are all similar to this:


assetType = db.define_table('assetType',
Field('assetTypeId', 'id'),
Field('name', length=50, required=True, unique=True),
format='%(name)s')


-Jim

Massimo Di Pierro

unread,
Jan 19, 2012, 2:36:20 PM1/19/12
to web2py-users
Now I know where to look for the fix. :-)

Massimo Di Pierro

unread,
Jan 20, 2012, 1:19:20 PM1/20/12
to web2py-users
can you check if trunk fixed it?

On Jan 19, 10:45 am, Jim Steil <j...@qlf.com> wrote:
> Hi
>
> Just updated to the latest trunk this morning and now my smartgrids
> aren't working where the table being used has links.
>
> Here is what I'm getting:
>
> Traceback(most recent call last):
>    File"C:\dev\web2py\gluon\restricted.py",line204,inrestricted
>      execccodeinenvironment
>    File"C:/dev/web2py/applications/infocenter/controllers/administration.py"  <http://127.0.0.1:8000/admin/default/edit/infocenter/controllers/admin...>,line1816,in<module>
>    File"C:\dev\web2py\gluon\globals.py",line172,in<lambda>
>      self._caller=lambdaf:f()
>    File"C:\dev\web2py\gluon\tools.py",line2530,inf
>      returnaction(*a, **b)
>    File"C:/dev/web2py/applications/infocenter/controllers/administration.py"  <http://127.0.0.1:8000/admin/default/edit/infocenter/controllers/admin...>,line457,inassetTypes
>      paginate=15,maxtextlength=45)
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1971,insmartgrid
>      user_signature=user_signature,**kwargs)
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1819,ingrid
>      iflink(row):
>    File"C:\dev\web2py\gluon\sqlhtml.py",line1968,in<lambda>

Jim Steil

unread,
Jan 20, 2012, 2:55:47 PM1/20/12
to web...@googlegroups.com
Massimo

I think I'm having trouble getting the latest from the trunk.  Here is what I'm seeing when I do a pull and then update:


I don't know enough about mercurial to know why this is.

I'm going to do a fresh install from trunk and see what happens.

    -Jim

Jim Steil

unread,
Jan 20, 2012, 3:00:06 PM1/20/12
to web...@googlegroups.com
Massimo

Just did a fresh - hg clone https://code.google.com/p/web2py

...added my app to that installation

and am seeing the same traceback I was getting yesterday.

Traceback (most recent call last):
  File "C:\Deleteme\web2py\gluon\restricted.py", line 204, in restricted
    exec ccode in environment
  File "C:/Deleteme/web2py/applications/infocenter/controllers/administration.py", line 1816, in <module>
  File "C:\Deleteme\web2py\gluon\globals.py", line 172, in <lambda>
    
self._caller = lambda f: f
()
  File "C:\Deleteme\web2py\gluon\tools.py", line 2530, in f
    return action(*a, **b)
  File "C:/Deleteme/web2py/applications/infocenter/controllers/administration.py", line 457, in assetTypes
    paginate=15, maxtextlength=45)
  File "C:\Deleteme\web2py\gluon\sqlhtml.py", line 1967, in smartgrid
    user_signature=user_signature,**kwargs)
  File "C:\Deleteme\web2py\gluon\sqlhtml.py", line 1815, in grid
    if link(row):
  File "C:\Deleteme\web2py\gluon\sqlhtml.py", line 1964, in <lambda>
    args=request.args[:nargs]+[args0,row.id])))
  File "C:\Deleteme\web2py\gluon\dal.py", line 4996, in __getattr__
    return self[key]
  File "C:\Deleteme\web2py\gluon\dal.py", line 4987, in __getitem__
    
return dict.__getitem__(self, key)
KeyError: 'id'
    -Jim

On 1/20/2012 12:19 PM, Massimo Di Pierro wrote:

rochacbruno

unread,
Jan 25, 2012, 1:51:58 AM1/25/12
to web...@googlegroups.com
I just got the same error

<type 'exceptions.KeyError'> '_id'



Traceback (most recent call last
):
File "/home/bruce/projects/web2py/gluon/restricted.py", line 204, in restricted
exec ccode in environment
File "/home/bruce/projects/web2py/applications/demo/controllers/appadmin.py", line 466, in <module>
File "/home/bruce/projects/web2py/gluon/globals.py", line 172, in <lambda>
self._caller = lambda f: f
()
File "/home/bruce/projects/web2py/applications/demo/controllers/appadmin.py", line 313, in update
if form.accepts(request.vars, session):
File "/home/bruce/projects/web2py/gluon/sqlhtml.py", line 1088, in accepts
hideerror=hideerror,
File "/home/bruce/projects/web2py/gluon/html.py", line 1807, in accepts
status = self._traverse(status,hideerror)
File "/home/bruce/projects/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
File "/home/bruce/projects/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
File "/home/bruce/projects/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
File "/home/bruce/projects/web2py/gluon/html.py", line 749, in _traverse
newstatus = c._traverse(status,hideerror) and newstatus
File "/home/bruce/projects/web2py/gluon/html.py", line 756, in _traverse
newstatus = self._validate()
File "/home/bruce/projects/web2py/gluon/html.py", line 1572, in _validate
(value, errors) = validator(value)
File "/home/bruce/projects/web2py/gluon/validators.py", line 549, in __call__
elif str(rows[0]._id) != str(self.record_id):
File "/home/bruce/projects/web2py/gluon/dal.py", line 5466, in __getattr__
return self[key]
File "/home/bruce/projects/web2py/gluon/dal.py", line 5457, in __getitem__
return dict.__getitem__(self, key)
KeyError: '_id'

with default auth_user table and some extra_fields added

Bruno Rocha

unread,
Jan 25, 2012, 1:55:40 AM1/25/12
to web...@googlegroups.com
I forgot to mention that the error was in /default/user/profile action
--

Bruno Rocha

unread,
Jan 25, 2012, 3:01:23 AM1/25/12
to web...@googlegroups.com, web2py-developers
Details in the issue on github https://github.com/mdipierro/web2py/issues/8

Jim Steil

unread,
Jan 26, 2012, 1:17:39 PM1/26/12
to web...@googlegroups.com
I've been away for a few days but came back today and updated my install again.  Now this is working on the list page from .smartgrid, but when I try to update a record I'm getting the following traceback...

Traceback (most recent call last):
  File "C:\dev\web2py\gluon\restricted.py", line 204, in restricted
    exec ccode in environment
  File "C:/dev/web2py/applications/infocenter/controllers/administration.py", line 1816, in <module>
  File "C:\dev\web2py\gluon\globals.py", line 172, in <lambda>
    self._caller = lambda f: f
()
  File "C:\dev\web2py\gluon\tools.py", line 2551, in f
    
return action(*a, **b)
  File "C:/dev/web2py/applications/infocenter/controllers/administration.py", line 457, in assetTypes
    paginate=15, maxtextlength=45
)
  File "C:\dev\web2py\gluon\sqlhtml.py", line 1975, in smartgrid
    user_signature=user_signature,**kwargs)
  File "C:\dev\web2py\gluon\sqlhtml.py", line 1593, in grid
    next=referrer)
  File "C:\dev\web2py\gluon\html.py", line 1960, in process
    self.validate(**kwargs)
  File "C:\dev\web2py\gluon\html.py", line 1907, in validate
    if self.accepts(**kwargs):
  File "C:\dev\web2py\gluon\sqlhtml.py", line 1088, in accepts
    hideerror=hideerror,
  File "C:\dev\web2py\gluon\html.py", line 1807, in accepts
    status = self._traverse(status,hideerror)
  File "C:\dev\web2py\gluon\html.py", line 749, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "C:\dev\web2py\gluon\html.py", line 749, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "C:\dev\web2py\gluon\html.py", line 749, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "C:\dev\web2py\gluon\html.py", line 749, in _traverse
    newstatus = c._traverse(status,hideerror) and newstatus
  File "C:\dev\web2py\gluon\html.py", line 756, in _traverse
    newstatus = self._validate()
  File "C:\dev\web2py\gluon\html.py", line 1572, in _validate
    (value, errors) = validator(value)
  File "C:\dev\web2py\gluon\validators.py", line 549, in __call__
    
elif str(rows[0]._id) != str(self.record_id
):
  File "C:\dev\web2py\gluon\dal.py", line 5466, in __getattr__
    return self[key]
  File "C:\dev\web2py\gluon\dal.py", line 5457, in __getitem__
    return dict.__getitem__(self, key)
KeyError: '_id'

I'm assuming it has something to do with my use of primary key-field being something other than 'id'.  Here is the setup for the tables being updated in this case:


assetType = db.define_table('assetType',
            Field('assetTypeId', 'id'),
            Field('name', length=50, required=True, unique=True),
            format='%(name)s')

assetType.name.requires = [IS_NOT_EMPTY(),
                           IS_NOT_IN_DB(db, 'assetType.name')]
assetType['_plural'] = 'Asset Types'

    -Jim

Carlos

unread,
Jan 26, 2012, 1:31:20 PM1/26/12
to web...@googlegroups.com
Hi,

I am not using smartgrid, and I am using regular tables (with the 'id' field), and I still get the same error (as described in my post):


I guess Massimo is still working on this?.

   Carlos

Jim Steil

unread,
Jan 26, 2012, 1:34:13 PM1/26/12
to web...@googlegroups.com
Thanks Carlos - not just me then...

Massimo Di Pierro

unread,
Jan 26, 2012, 1:55:54 PM1/26/12
to web2py-users
please check trunk again.

Jim Steil

unread,
Jan 26, 2012, 4:30:35 PM1/26/12
to web...@googlegroups.com
That fixed it. Thanks Massimo!

-Jim

Reply all
Reply to author
Forward
0 new messages