Matt Wilson schrieb:
> On Nov 30, 5:44 am, Christopher Arndt <[EMAIL PROTECTED]> wrote:
>> @validate(validators={'sh': MyValidator()})
>> def drawform(self, sh, tg_errors=None):
>> """Draw the form."""
>> if isinstance(sh, basestring):
>> # or check for the type your validator returns
>> try:
>> sh = MyValidator()._to_python(sh)
>> except validators.Invalid, exc:
>> tg_errors['sh'] = exc
>> if tg_errors:
>> ...
>> return dict(myform=myform)
> Is it just me, or does this pattern seem a little weird? I wish that
> validation errors in one validator wouldn't cause the system to skip
> ALL validation everywhere.
Yes, I'm not too happy with the situation as it is now. The pattern
where you have shown in your example, e.g. a) a method that takes a
single param and shows a form with some (hidden) values preset and b)
another form that process the form submission, is very common. Because
the validate decorator will run validation only once, you have to resort
to this hacky code to get the parameter to a) validated when the first
method is called as an error handler of b).
http://trac.turbogears.org/browser/branches/1.1/turbogears/controllers.py#L158
See also this ticket:
http://trac.turbogears.org/ticket/1993
The recursion guard was put in for a reason, which was discussed on the
mailing list a while ago and seemed sensible me to me back then but I
can't remember exactly anymore what is was exactly ;) I think Christoph
Zwerschke let the discussion back then, maybe he can comment?
If you have any suggestions how to handle this issue better, I'd be very
interested to hear it!
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---