Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Private Attributes
plone.app.form.exception.WidgetInputErrorView Class Reference

List of all members.

Public Member Functions

def __init__
def snippet

Public Attributes

 request

Static Private Attributes

 __used_for__ = IWidgetInputError

Detailed Description

A widget error view that hardcodes no html

Definition at line 11 of file exception.py.


Constructor & Destructor Documentation

def plone.app.form.exception.WidgetInputErrorView.__init__ (   self,
  context,
  request 
)

Definition at line 17 of file exception.py.

00017 
00018     def __init__(self, context, request):
00019         self.context, self.request = context, request

Here is the caller graph for this function:


Member Function Documentation

Convert a widget input error to an html snippet

>>> from zope.app.form.interfaces import WidgetInputError
>>> 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'

The only method that IWidgetInputError promises to implement is
`doc()`. Therefore, other implementations of the interface should also
work.

>>> from zope.app.form.interfaces import ConversionError
>>> err = ConversionError('Could not convert to float.')
>>> view = WidgetInputErrorView(err, None)
>>> view.snippet()
u'Could not convert to float.'

Definition at line 20 of file exception.py.

00020 
00021     def snippet(self):
00022         """Convert a widget input error to an html snippet
00023 
00024         >>> from zope.app.form.interfaces import WidgetInputError
00025         >>> class TooSmallError(object):
00026         ...     def doc(self):
00027         ...         return "Foo input < 1"
00028         >>> err = WidgetInputError("foo", "Foo", TooSmallError())
00029         >>> view = WidgetInputErrorView(err, None)
00030         >>> view.snippet()
00031         u'Foo input &lt; 1'
00032 
00033         The only method that IWidgetInputError promises to implement is
00034         `doc()`. Therefore, other implementations of the interface should also
00035         work.
00036 
00037         >>> from zope.app.form.interfaces import ConversionError
00038         >>> err = ConversionError('Could not convert to float.')
00039         >>> view = WidgetInputErrorView(err, None)
00040         >>> view.snippet()
00041         u'Could not convert to float.'
00042         """
00043         message = self.context.doc()
00044         translated = translate(message, context=self.request, default=message)
00045         return u'%s' % escape(translated)

Member Data Documentation

plone.app.form.exception.WidgetInputErrorView.__used_for__ = IWidgetInputError [static, private]

Definition at line 15 of file exception.py.

Definition at line 18 of file exception.py.


The documentation for this class was generated from the following file: