On Nov 30, 5:44 am, Christopher Arndt <[EMAIL PROTECTED]> wrote:
> Matt Wilson wrote:
> > For the code below, when processform kicks back to drawform, how do I
> > run the MyValidator on the sh parameter?
>
> > @validate(validators={'sh':MyValidator()})
> > def drawform(self, sh, tg_errors=None):
> > "draw the form"
> > return dict(myform=myform)
>
> > @validate(form=myform)
> > @error_handler(drawform)
> > def processform(self, **kwargs):
> > "save the data"
>
> @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)
>
> Hth, Chris
Thanks Chris!
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.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---