I recently updated my web2py source code from the mercurial repository
I think that something has changed in SQLFORM that is incompatible
with custom id field names declared with:
Field("other_id", ...)
On form processing, record updates stop the app with this error:
Traceback (most recent call last):
File "/home/alan/gestionlibre/gestionlibre_gui-hg/controllers/
appadmin.py", line 178, in update
if session.form.accepts(evt.args, formname=None, keepvalues=False,
dbio=False):
File "/home/alan/web2py-hg/gluon/sqlhtml.py", line 1050, in accepts
(formname_id, record_id) = (self.record[id_fieldname],
File "/home/alan/web2py-hg/gluon/dal.py", line 4987, in __getitem__
return dict.__getitem__(self, key)
I managed to solve the problem for updates by changing sqlhtml.py in
this way:
(Line 1039)
# retrieve the actual id name (for legacy databases)
try:
id_fieldname = self.table.id.name
except (IndexError, AttributeError):
# could not retrieve the table id value
id_fieldname = "id"
# former notation was self.record.id Check for
compatibility
(formname_id, record_id) = (self.record[id_fieldname],
request_vars.get('id',
None))
The problem seems to be related to SQLFORM trying to get the default
id key from table records, and may reproduce in other instances, since
I see that the record.id property is being called in other sections of
the module.
I'd continue with the fix to provide a complete modification of the
module if the solution provided has no backward compatibility or other
problems.
Thanks