tml schrieb:
> [...]
> 
> def new(..):
>  ...
>  return dict(form=new_post, action='/save?id='+self.id)
> 
> def edit(..):
>  ...
>  return dict(form=new_post, action='/save?id='+self.id)
> 
> @expose()
> @validate(form=new_post)
> @error_handler()
> def save(...args...):
>    ...
> 
> Now in above code, save() is called from both new and edit. But, if
> the validator fails, i want it to go back to the page it came from
> (eithr new or edit). How do i do this?? If i use redirect() inside
> save(), then the arguments which were given in the pages' post are all
> cleared!
> 
> Can someone tell me how i can use validators the right way in this
> situation?

In terms of validators, leave everything where it is.

Then, do something like this in 'save' (which needs the tg_errors=None
parameter):
    if tg_errors:
        tg.flash('Try again.')
        return self.new(...)
    else:
        # some processing
        redirect... # to edit

Well, the address wouldn't have changed but at least you can let the
user correct his inputs.

-- Mark

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to