[Zope3-Users] z3c.form - how to raise/create an error in an
action?
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Aug 14 11:49:41 EDT 2007
On Monday 13 August 2007 15:00, Hermann Himmelbauer wrote:
> 1) The user enters an ID, which is invalid/unknown. In this
> case, "invalid/unknown ID" should be denoted for the widget and in the form
> status.
I have implemented the necessary framework to handle this case.
> 2) The user enters the name. In case there are no matching records, a "not
> found" error message should be displayed in the form status, which is not
> widget-related.
If you simply want to change the form *status*, you can do so by setting:
form.status = u'My message'
> 1) Widget-specific error: Somehow set the error field, e.g. in the action:
>
> self.widgets['myIDfield'].error="Invalid/unknown ID"
> Another variant would be to raise a specific error, like this:
>
> raise WidgetActionError(['myIDfield', 'invalid/unknown ID'])
>
> 2) Generic error: Raise an exception, similar like in invariants:
>
> raise Invalid("No data was found")
I do not like any error to be raised, since this could hide real errors.
Instead you must raise a special type of error that is than handled. See my
latest checkin or read the documentation in form.txt.
These new features are in the trunk and will be part of the next release.
Regards,
Stephan
--
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
More information about the Zope3-users
mailing list