I think I may be going about this wrong, but I want to throw new form 
errors if something happens after doing form.accepts(...). I'm not using 
SQLFORM or CRUD, just the FORM().

The scenario is something like this: The user enters payment information 
correctly, but when I charge the card, the card is returned declined. Then, 
the form should display an error saying that there are errors with the card 
and present the user with the form again, as though validation had failed. 
The same flow would go with emailing the user too.


form = FORM(...)

if form.accepts(request, session):
    try:
         makePayment(....)    
         redirect(URL('successful_payment'))   # Redirect after success
    except ...
         # Display Errors on form here and show the form to the user.

elif form.errors:   # Validation has failed
    response.flash = 'form has errors'



What would go in the except block?

-- 



Reply via email to