Hi Ben,

Ben Bangert wrote:
> On Aug 28, 2006, at 10:29 PM, pymonger wrote:
>
> > Quick question:  How can I validate arguments sent through a GET
> > (similar to the validate
> > decorator in TurboGears)?
>
> Right now, you can't, as you noted below, its not geared towards GET at
> this moment.

OK.

>
> > In my controller I have this method:
> >
> >     @validate(validators={"count": validators.Int()})
> >     def getCount(self,count):
> >         return Response('<b>%d</b>' % count)
> >
> > however when I navigate there with
> > http://bogus.hostname.here:5000/ping/getCount/123
>
> Where would this redirect to if the count isn't an int?
>
> > I looked at the validate function under pylons.decorators but it looks
> > geared to
> > validating form data that is POSTed.  I probably missed something.
>
> No, that's correct. It is currently geared to POST variables. Though I
> see no issue with adapting it to handle GET variables as well. If it
> was to work on GET variables, I'd assume that it would give you the new
> coerced dict inside the action under:
>    self.validation_results
> Or something like that, as right now a validated POST is under
> self.form_results. Having it pass in the variable in the function def
> is a little outside the normal operating scope of a Pylons controller,
> as the variables in the function come from Route arguments, not
> GET/POST params.
>
> Any ideas on what you'd like usage of it to look like, and how/where
> should it fail over to should the validation fail?

Perhaps an additional argument that specifies the url to redirect to
upon 
an invalid argument type.

G

> 
> HTH,
> Ben


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss
-~----------~----~----~----~------~----~------~--~---

Reply via email to