Part of lp.app.validators View In Hierarchy
This is used to override the default Z3 one which blindly HTML encodes error messages.
Method | snippet | Convert a widget input error to an html snippet |
Convert a widget input error to an html snippet
If the error implements provides a snippet() method, just return it. Otherwise return the error message.
>>> from zope.formlib.interfaces import WidgetInputError >>> from lp.services.webapp.escaping import structured >>> bold_error = LaunchpadValidationError(structured("<b>Foo</b>")) >>> err = WidgetInputError("foo", "Foo", bold_error) >>> view = WidgetInputErrorView(err, None) >>> view.snippet() u'<b>Foo</b>'
>>> class TooSmallError(object): ... def doc(self): ... return "Foo input < 1" >>> err = WidgetInputError("foo", "Foo", TooSmallError()) >>> view = WidgetInputErrorView(err, None) >>> view.snippet() u'Foo input < 1'