I still find the formlib validation machinery a bit confusing, I'm afraid...
I have a form which saves values in a relational database. Because of
concurrent requests, it's possible that a key constraint in the database
may be violated on save. I can't know this until the actual action
The error would relate to a particular field (basically, the field is an
integer whose value can't be above a number N, where N is dependent on
the current state of the database, think something like a booking
database where you request tickets, but others may have snatched the
last remaining tickets before you hit Save).
I'd like to be able to catch a database-layer exception in the form
action handler method and then have the form return with a status
indicating an error on a particular field, with the form values filled in.
I've done interface constraints before and raised ValidationErrors.
However, in this case that won't work because the error can only occur
during the action handler (and without access to the request, which
carries a particular foreign key, I can't look in the database to
predict whether it would fail).
Is there some way of doing this?
Zope3-users mailing list