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!"
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.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---