l.a.v.WidgetInputErrorView(Z3WidgetInputErrorView) : class documentation

Part of lp.app.validators View In Hierarchy

Display an input error as a snippet of text.

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
def snippet(self):

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()
>>> class TooSmallError(object):
...     def doc(self):
...         return "Foo input < 1"
>>> err = WidgetInputError("foo", "Foo", TooSmallError())
>>> view = WidgetInputErrorView(err, None)
>>> view.snippet()
u'Foo input &lt; 1'
API Documentation for Launchpad, generated by pydoctor at 2019-10-20 00:00:13.