def submission(self, **form): try: values = forms.validate_submission(form) errors = {} except forms.Invalid, e: values = e.value errors = e.unpack_errors()
def index(self, **form): if cherrypy.request.method == "GET": return serve_template('index.html', form=forms.render_submission()) if cherrypy.request.method == "POST": try: values = forms.validate_submission(form) except forms.Invalid, e: return serve_template('index.html', form=forms.render_submission( defaults=e.value, errors=e.unpack_errors())) else: save_submission(values) raise cherrypy.HTTPRedirect("thankyou")