Hi, The z3c.form doctests make it look like raising zope.interface.Invalid() would be an acceptable thing for a validator to do. It also makes it look like the argument passed to the Invalid() constructor is a string that would be displayed as an error message. However, when I do this (in a constraint or a IValidator adapter), the exception is not caught, and so causes a traceback. In field.py, we have:: try: widget.setErrors = self.setErrors raw = widget.extract() if raw is not interfaces.NO_VALUE: value = interfaces.IDataConverter(widget).toFieldValue(raw) zope.component.getMultiAdapter( (self.content, self.request, self.form, getattr(widget, 'field', None), widget), interfaces.IValidator).validate(value) except (zope.schema.ValidationError, ValueError, MultipleErrors), error: view = zope.component.getMultiAdapter( (error, self.request, widget, widget.field, self.form, self.content), interfaces.IErrorViewSnippet) view.update() if self.setErrors: widget.error = view errors += (view,) And indeed, this doesn't catch Invalid. In error.py, on the other hand, there is an InvalidErrorViewSnippet. Is this intentional? Martin -- Author of `Professional Plone Development`, a book for developers who want to work with Plone. See http://martinaspeli.net/plone-book
On Friday 26 February 2010, Martin Aspeli wrote:
The z3c.form doctests make it look like raising zope.interface.Invalid() would be an acceptable thing for a validator to do. It also makes it look like the argument passed to the Invalid() constructor is a string that would be displayed as an error message.
After reviewing the code and comments briefly, I think this is a bug. I am amazed that it has not surfaced before. I guess Invalid from zope.interface is simply not raised that often. Feel free to fix the bug with a test. You can also release a new z3c.form version if you like. I can give you access Regards, Stephan -- Entrepreneur and Software Geek Google me. "Zope Stephan Richter"
Stephan Richter wrote:
On Friday 26 February 2010, Martin Aspeli wrote:
The z3c.form doctests make it look like raising zope.interface.Invalid() would be an acceptable thing for a validator to do. It also makes it look like the argument passed to the Invalid() constructor is a string that would be displayed as an error message.
After reviewing the code and comments briefly, I think this is a bug. I am amazed that it has not surfaced before. I guess Invalid from zope.interface is simply not raised that often.
Feel free to fix the bug with a test. You can also release a new z3c.form version if you like. I can give you access
Fixed. I also added the behaviour to not render anything for a non-200 request. My PyPI username is optilude if you'd like me to release it a 2.3.3. Martin -- Author of `Professional Plone Development`, a book for developers who want to work with Plone. See http://martinaspeli.net/plone-book
On 02/26/2010 04:23 PM, Martin Aspeli wrote:
Stephan Richter wrote:
On Friday 26 February 2010, Martin Aspeli wrote:
The z3c.form doctests make it look like raising zope.interface.Invalid() would be an acceptable thing for a validator to do. It also makes it look like the argument passed to the Invalid() constructor is a string that would be displayed as an error message.
After reviewing the code and comments briefly, I think this is a bug. I am amazed that it has not surfaced before. I guess Invalid from zope.interface is simply not raised that often.
Feel free to fix the bug with a test. You can also release a new z3c.form version if you like. I can give you access
Fixed.
I also added the behaviour to not render anything for a non-200 request.
Yay! -- Christian Theune · ct@gocept.com gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany http://gocept.com · tel +49 345 1229889 0 · fax +49 345 1229889 1 Zope and Plone consulting and development
On Friday 26 February 2010, Martin Aspeli wrote:
Feel free to fix the bug with a test. You can also release a new z3c.form version if you like. I can give you access
Fixed.
I also added the behaviour to not render anything for a non-200 request.
My PyPI username is optilude if you'd like me to release it a 2.3.3.
Thanks for your work. I gave you access to z3c.form, z3c.formui and z3c.formdemo, which are all related. Regards, Stephan -- Entrepreneur and Software Geek Google me. "Zope Stephan Richter"
participants (3)
-
Christian Theune -
Martin Aspeli -
Stephan Richter