[ZPT] exceptions
Evan Simpson
evan@digicool.com
Tue, 26 Jun 2001 10:53:23 -0500
From: "Magnus Heino (Rivermen)" <magnus.heino@rivermen.se>
> How can I do this with ZPT? Catch an specific exception and read the
error.
In this particular instance, I would put the validation call into a
Script, like this:
## Script (Python) "is_valid"
##parameters=
try:
context.form.validate_all_to_request(context.REQUEST)
except FormValidationError:
return 0
return 1
<ul tal:condition="not:here/is_valid">
<li tal:repeat="error request/error_value/errors">
<span tal:replace="field.get_value('title')">Title</span>:
<span tal:replace="error/error_text">Error</span>
</li>
</ul>
Another approach would be to place the error body in a DTML Method,
render that in the Script, and use tal:replace="structure
here/error_if_not_valid" to insert the text returned by the Script.
Cheers,
Evan @ digicool