Hi Massimo, Traceback (most recent call last): File "\web2py\gluon\restricted.py", line 205, in restricted exec ccode in environment File "/web2py/applications/pg/controllers/appadmin.py" <http://192.168.37.50:8000/admin/default/edit/pg/controllers/appadmin.py>, line 410, in <module> File "\web2py\gluon\globals.py", line 173, in <lambda> self._caller = lambda f: f() File "/web2py/applications/pg/controllers/appadmin.py" <http://192.168.37.50:8000/admin/default/edit/pg/controllers/appadmin.py>, line 126, in insert form = SQLFORM(db[table], ignore_rw=ignore_rw) File "\web2py\gluon\sqlhtml.py", line 868, in __init__ inp = self.widgets.options.widget(field, default) File "\web2py\gluon\sqlhtml.py", line 216, in widget options = requires[0].options() File "\web2py\gluon\validators.py", line 465, in options self.build_set() File "\web2py\gluon\validators.py", line 458, in build_set self.theset = [str(r[self.kfield]) for r in records] File "\web2py\gluon\dal.py", line 5648, in __getitem__ return dict.__getitem__(self, key) KeyError: 'id'
Thanks, Jerry. On Wednesday, July 11, 2012 7:07:16 AM UTC-7, Massimo Di Pierro wrote: > > Do you have a longer traceback? It would help to know which line in > tools.py is causing the problem. > > It is true that Auth assumes the id field for auth tables to be called id. > Perhaps this can be changed. > > Massimo > > On Wednesday, 11 July 2012 01:10:17 UTC-5, Jerry wrote: >> >> Hello, >> >> I have a legacy MS SQL db with a User table with lots of old data: >> >> db3.define_table('People', >> Field('People_ID', 'id'), >> Field('LastName', length=50), >> Field('FirstName', length=50), >> ........ >> migrate = False >> ) >> custom_auth_table = db3['People'] >> >> # tell Auth to use this table >> auth.settings.table_user = custom_auth_table >> >> # have Auth create the group, membership etc. tables >> auth.define_tables() >> >> I can view tables, including the legacy People via Admin - the new auth >> tables don't contain any data - and create a new group in auth_group no >> problem. >> >> When I try to insert a new auth_membership: >> /appadmin/insert/db3/auth_membership >> CPU utilization goes to 100% for a couple of seconds and I get an error: >> >> File "\web2py\gluon\dal.py", line 5648, in __getitem__ >> return dict.__getitem__(self, key) >> KeyError: 'id' >> >> Variables self <Row {'auth_event': <gluon.dal.Set object at >> 0x0...lete_record': <function <lambda> at 0x08A866B0>}> dict.__getitem__ >> <method >> '__getitem__' of 'dict' objects> builtindict <type 'dict'> key 'id' >> I suspect the error has something to do with the 'id' field of the User >> table ('People') being 'People_ID' instead of 'id'. >> However looking at the db auth_membership table definition, the 'user_id' >> column seems correct - a Foreign Key pointing to 'People' / 'People_ID'. >> I'm stumped. >> >> Any ideas? >> >> Thanks, >> >> Jerry. >> >