When I submit a form created with .factory(), on validation web2py throws this 
error:

Traceback (most recent call last):
  File "/home/alan/web2py/web2py-hg/gluon/restricted.py", line 205, in 
restricted
    exec ccode in environment
  File "/home/alan/web2py/web2py-hg/applications/pyodel/controllers/wizard.py" 
<http://127.0.0.1:8000/admin/default/edit/pyodel/controllers/wizard.py>, line 
414, in <module>
  File "/home/alan/web2py/web2py-hg/gluon/globals.py", line 175, in <lambda>
    self._caller = lambda f: f()
  File "/home/alan/web2py/web2py-hg/applications/pyodel/controllers/wizard.py" 
<http://127.0.0.1:8000/admin/default/edit/pyodel/controllers/wizard.py>, line 
221, in quiz
    if form.process().accepted:
  File "/home/alan/web2py/web2py-hg/gluon/html.py", line 2004, in process
    self.validate(**kwargs)
  File "/home/alan/web2py/web2py-hg/gluon/html.py", line 1951, in validate
    if self.accepts(**kwargs):
  File "/home/alan/web2py/web2py-hg/gluon/sqlhtml.py", line 1040, in accepts
    try:
AttributeError: 'SQLFORM' object has no attribute try:
'readonly'


I think that cause of the error is that the code that initializes the form 
doesn't set the object's readonly attribute.

I solved the problem by using a try-except block here.

# gluon/sqlhtml.py line 1040
try:
    if self.readonly: return False
except AttributeError, e:
    self.readonly = False



Anyway, this is not a proper patch. The correct one should set the readonly 
attribute on form instantiation. My web2py version is Version 1.99.7 
(2012-04-01 23:37:42) dev

Reply via email to