Hi,

Can SQLFORM.grid be used to display legacy tables, specifically a
table that doesn't have a field named 'id', and if so, how?

The following is an example of a table I'm currently using in the
latest trunk.  Dbadmin displays it successfully, but web2py throws an
exception
when I try to display it with grid.

The table is defined as:

db2.define_table('statuspoint',
     Field('pointnumber','integer'),
     Field('pointname','string'),
     Field('pointaccessarea','integer'),
     Field('station','integer'),
     primarykey=['pointnumber'],
     migrate=False
)

Controller:
def grid():
    form = SQLFORM.grid(db2.statuspoint)
    return dict(form=form)

Error:
  File "/home/xa21/web2py/gluon/dal.py", line 4522, in __call__
    query = query._id>0
  File "/home/xa21/web2py/gluon/dal.py", line 4916, in __getattr__
    return self[key]
  File "/home/xa21/web2py/gluon/dal.py", line 4860, in __getitem__
    return dict.__getitem__(self, str(key))
KeyError: '_id'

- Thanks in advance, - Tom

Reply via email to