I'm using a legacy database that has a table with multiple columns in
the primary key (If I could, I would change it).
When inserting into this table, I get the following error:
File "/home/loren/dev/web2py/gluon/dal.py", line 774, in insert
return dict( [ (k,fields[k]) for k in table._primarykey ])
TypeError: list indices must be integers, not str
Some context for this line, in dal.py:
except Exception, e:
if isinstance(e,self.integrity_error_class()):
return None
raise e
if hasattr(table,'_primarykey'):
return dict( [ (k,fields[k]) for k in table._primarykey ])
id = self.lastrowid(table)
if not isinstance(id,int):
return id
rid = Reference(id)
I was able to fix this by simply replacing the line with:
return dict([(k[0].name, k[1]) for k in fields if k[0].name in
table._primarykey])