[Zope] Formulator, Python Scripts and Exception Data
Casey Duncan
c.duncan@nlada.org
Wed, 2 Jan 2002 12:11:11 -0500
I am trying to use Python scripts in Zope 2.3 to validate a Formulator form,
however I run into a couple of snags:
- Formulator raises a class-based exception FormValidationError, which I am
not authorized to import TTW.
- Formulator returns the error data with the exception.
So, my catch22 is that in order to successfully catch the exception, I must
use a bare except clause, which of course does not allow me to get at the
exception data (AFAIK), since I cannot specify a variable for it in except
nor can I import sys and get at it that way.
So the following things don't work:
from Products.Formulator.Form import FormValidationError
try:
...validation stuff...
except FormValiadationError, errors:
...deal with errors...
-- or --
try:
...validation stuff...
except:
...deal with errors, except there's no way to get at them 8^(...
Poking through the source didn't illuminate any built-in trick to get around
this.
The irony is that I can use DTML to do this, since it is more forgiving about
exception names, but I don't want to use DTML for this, it is not a template,
just a validation script.
Anybody got a good solution (besides external methods)?
/---------------------------------------------------\
Casey Duncan, Sr. Web Developer
National Legal Aid and Defender Association
c.duncan@nlada.org
\---------------------------------------------------/