[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces - form.py:1.5

Stuart Bishop zen@shangri-la.dropbear.id.au
Mon, 14 Jul 2003 11:29:05 -0400


Update of /cvs-repository/Zope3/src/zope/app/interfaces
In directory cvs.zope.org:/tmp/cvs-serv24906/src/zope/app/interfaces

Modified Files:
	form.py 
Log Message:
- Make Widget validation errors humanly readable, it a half-arsed sort of way.
  Widgets have spawned an 'error' attribute, set by getData.
- Display validation errors next to the dud input in Widget.row()
- Make description a tooltip of a Widget's label. This is currently done
  by abusing the <acronym> tag.
- addwizard and editwizard work again with the recent editview changes



=== Zope3/src/zope/app/interfaces/form.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/interfaces/form.py:1.4	Sun Jul 13 02:47:25 2003
+++ Zope3/src/zope/app/interfaces/form.py	Mon Jul 14 11:28:30 2003
@@ -16,20 +16,32 @@
 $Id$
 """
 
+import cgi
 from zope.schema.interfaces import ValidationError
 from zope.component.interfaces import IView
-from zope.interface import Attribute
+from zope.interface import Attribute, Interface, implements
+from zope.app.interfaces.exceptions import UserError
 
+class IWidgetInputError(Interface):
+    'Placeholder for a snippet View'
+    pass
 
-class WidgetInputError(Exception):
+class WidgetInputError(UserError):
     """There were one or more user input errors
     """
+    implements(IWidgetInputError)
 
     def __init__(self, field_name, widget_title, errors):
-        Exception.__init__(self, field_name, widget_title, errors)
+        ''' errors is a ValidationError '''
+        UserError.__init__(self, field_name, widget_title, errors)
         self.field_name = field_name
         self.widget_title = widget_title
         self.errors = errors
+
+class WidgetInputErrorView:
+    __used_for__ = IWidgetInputError
+    def snippet(self):
+        return '<span class="error">%s</span>' % self.context.errors[0]
 
 class MissingInputError(WidgetInputError):
     """Required data was not supplied