I would like to direct your attention to Widget.validate. Currently we
delete any non-conforming arguments. This is a very very nasty
side-effect. If nothing else, it can trip any method validating
positional arguments (e.g. turbogears/tests/test_form_controllers.py).
Cheers,
Simon
There is also a pending ticket on this aspect:
http://trac.turbogears.org/turbogears/ticket/476
Ciao
Michele
I think passing unexpected values to a method is less of a problem now,
since the method has to be explicitly aware (either via error_handler
decorator, or tg_errors parameter) of the possibility of an invalid value.
Simon
True, to a point. There's always a little more complexity right around
the corner when you're trying to make something simple.
Imagine a widget that lets you pick a person from the database to
associate with a record. The web will pass in an integer id, and the
method will get an object on the way in. But, if that doesn't validate
for some reason, the user will see the form again and that int will
still be there. The validator whose job it is to convert the original
Person object into an int will get an int instead.
That's more of an edge case, though, and can be handled by writing the
validator's from_python method usefully and with that understanding.
Excepting that, I'm in agreement that it's a lot more pleasant to
leave the value untouched.
Kevin
That, or pass controll to another method or widget.
> Excepting that, I'm in agreement that it's a lot more pleasant to
> leave the value untouched.
Shall I make the change than?
Simon
Go for it.
Thanks!
Kevin
Related to validation errors, I've also updated #315 (form_errors ->
validation_errors).
Ciao
Michele