No, the issue is not related to WebGrid. The problem is that crud.db (which is essentially passed to WebGrid) is a different object than your second DAL instance (even though it has the same name) and your WebGrid data source is attempting to use a table from the second DAL instance. You can see what I mean with this controller action:
def tables(): print crud.db.tables print db.tables On May 9, 3:57 am, winti <stefan.winterb...@gmail.com> wrote: > It's true, when i delete/adjust the db definition statement it's > working. > It seems, when i choose another name as "db" webgrid can not handle > this. Is that true ? > > Stefan > > On May 8, 9:59 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > Did you delete the default DAL declaration at the top of db.py? Your > > code works for me. > > > On May 8, 2:04 pm, winti <stefan.winterb...@gmail.com> wrote: > > > > i changed it to myid and i get a error on: > > > KeyError: 'myid' > > > > Stefan > > > > On May 8, 8:51 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > > > 'identity' is probably a reserved word in sqlite. Try changing it to > > > > something else. > > > > > On May 8, 1:36 pm, winti <stefan.winterb...@gmail.com> wrote: > > > > > > Hello, > > > > > in a controller i define a temp db and want to return the results with > > > > > webgrid to a view. > > > > > I get a Keyerror on 'identity'. > > > > > > Traceback (most recent call last): > > > > > File "/data/projects/frameworks/web2py/applications/gluon/ > > > > > restricted.py", line 178, in restricted > > > > > exec ccode in environment > > > > > File "/data/projects/frameworks/web2py/applications/applications/ > > > > > eDir/controllers/default.py", line 190, in <module> > > > > > File "/data/projects/frameworks/web2py/applications/gluon/ > > > > > globals.py", line 96, in <lambda> > > > > > self._caller = lambda f: f() > > > > > File "/data/projects/frameworks/web2py/applications/applications/ > > > > > eDir/controllers/default.py", line 187, in queryaddr > > > > > return dict(resi1=res,grid=grid()) > > > > > File "/data/projects/frameworks/web2py/applications/applications/ > > > > > eDir/modules/webgrid.py", line 229, in __call__ > > > > > field = db[t][f] > > > > > File "/data/projects/frameworks/web2py/applications/gluon/sql.py", > > > > > line 1318, in __getitem__ > > > > > return dict.__getitem__(self, str(key)) > > > > > KeyError: 'identity' > > > > > > def xyz(): > > > > > > db=SQLDB('sqlite:memory:') > > > > > db.define_table("identity", > > > > > db.Field("user","string",default=""), > > > > > db.Field("ip","string",default=""), > > > > > db.Field("type","string",default="")) > > > > > > ... > > > > > ... > > > > > .... > > > > > db.identity.insert(user=user,ip=ipreadeable,type=type) > > > > > ... > > > > > ... > > > > > > grid = webgrid.WebGrid(crud) > > > > > grid.datasource = db(db.identity.id<0).select() > > > > > > Any idea > > > > > > Stefan