Destructive Widget.validate

0 views
Skip to first unread message

Simon Belak

unread,
Feb 8, 2006, 8:12:07 AM2/8/06
to turbo...@googlegroups.com
Hi,

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

Michele Cella

unread,
Feb 8, 2006, 8:16:50 AM2/8/06
to TurboGears

There is also a pending ticket on this aspect:

http://trac.turbogears.org/turbogears/ticket/476

Ciao
Michele

Simon Belak

unread,
Feb 8, 2006, 9:05:02 AM2/8/06
to turbo...@googlegroups.com
Thanks.

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

Kevin Dangoor

unread,
Feb 8, 2006, 10:45:30 AM2/8/06
to turbo...@googlegroups.com
On 2/8/06, Simon Belak <simon...@hruska.si> wrote:
> 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.

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

Simon Belak

unread,
Feb 8, 2006, 10:59:30 AM2/8/06
to turbo...@googlegroups.com

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

Kevin Dangoor

unread,
Feb 8, 2006, 11:23:16 AM2/8/06
to turbo...@googlegroups.com
> > Excepting that, I'm in agreement that it's a lot more pleasant to
> > leave the value untouched.
>
> Shall I make the change than?

Go for it.

Thanks!
Kevin

Michele Cella

unread,
Feb 8, 2006, 11:34:11 AM2/8/06
to TurboGears

Related to validation errors, I've also updated #315 (form_errors ->
validation_errors).

Ciao
Michele

Reply all
Reply to author
Forward
0 new messages