On Wed, Apr 16, 2008 at 3:52 PM, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
>
>  I'm a little unclear on your goals, so the answer is yes and not
>  really. ;)
>
>  This refactoring will let the form validate as a decorator, and then
>  allow you to cause an error within your pylons function
>
>  @validate( blah )
>  def stuff( self ):
>   # yay, form is valid
>   if not record_in_database('foo'):
>         c.form_errors['foo']= "nuh uh"
>
>         return validation_error( self, form= '_password_change_print',
>  post_only= True )
>   return "yay!"

That solves another problem we have: how to trigger a form error in
the action after the validator has passed.

>  However.. you can't validate a form within a function... at least i
>  don't think so.. i haven't tried to hack that.
>
>  I kind of want to make a another split on this functionality, so there
>  are 3 distinct tasks:
>
>  My ideal @validate would do this:
>
>  @validate-
>   valid= validate_form
>   if not valid and auto_error:
>      validate_error
>
>  validate_form - returns True/False on form validity
>  validate_error - causes the form to error at any point
>
>  With that in place, you have a VERY useful and extensible validation
>  system that can do just about anything. It might be possible to call
>  @validate within a controller method currently.  I honestly haven't
>  tried it.

Normally you don't want to decorators in non-decorator situations, so
you'd need another function for this.

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to