Trying to follow the Pylons/twForms tutorial
(http://wiki.pylonshq.com/display/toscawidgets/Using+twForms+with+Pylons.+Part+1)
I get the following traceback when trying to render the form:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/src/ToscaWidgets/toscawidgets/core.py", line 461, in __call__ return self.display(value, **kw)
File "/usr/local/src/ToscaWidgets/toscawidgets/core.py", line 457, in display
kw = self.prepare_dict(value, kw)
File "/usr/local/src/ToscaWidgetsForms/toscawidgets/widgets/forms/core.py", line 191, in prepare_dict
kw = super(InputWidget, self).prepare_dict(value, kw, adapt=False)
File "/usr/local/src/ToscaWidgets/toscawidgets/core.py", line 501, in prepare_dict
self.update_params(d)
File "/usr/local/src/ToscaWidgetsForms/toscawidgets/widgets/forms/fields.py", line 239, in update_params
super(Form, self).update_params(d)
File "/usr/local/src/ToscaWidgetsForms/toscawidgets/widgets/forms/fields.py", line 107, in update_params
super(FormField,self).update_params(d)
File "/usr/local/src/ToscaWidgetsForms/toscawidgets/widgets/forms/core.py", line 207, in update_params
super(InputWidget, self).update_params(d)
File "/usr/local/src/ToscaWidgets/toscawidgets/core.py", line 568, in update_params
attr = getattr(self,k,None)
File "/usr/local/src/ToscaWidgetsForms/toscawidgets/widgets/forms/fields.py", line 89, in is_required
self.validate('', use_request_local=False)
File "/usr/local/src/ToscaWidgetsForms/toscawidgets/widgets/forms/core.py", line 129, in validate
value = self.validator.to_python(value, state)
File "/usr/local/src/FormEncode/formencode/api.py", line 380, in to_python
value = tp(value, state)
File "/usr/local/src/FormEncode/formencode/schema.py", line 164, in _to_python except KeyError:
TypeError: unbound method message() must be called with DefaultValidator instance as first argument (got str instance instead)
using FormEncode 0.7.2dev-r3105, ToscaWidgets? 0.1a2dev-r3614 and twForms 0.1a2dev-r3616.
The problem seems to come from the form's schema validators all being the DefaultValidator class itself, on which Schema._to_python calls the instance method message(). The relevant part of code is in formencode.schema, lines 152 to 173. I first thought there was a typo with InputWidget using the DefaultValidator class (instead of an instance of...), but it looks like it's by design since there are a couple of places where InputWidget.validator is identity tested against DefaultValidator, so...
NB : of course, the form renders ok when validators are explicitely added to the fields.