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

Garrett Smith garrett at mojave-corp.com
Tue May 11 07:11:53 EDT 2004


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

Modified Files:
	__init__.py 
Log Message:
Created InputWidget mixin.


=== Zope3/src/zope/app/form/__init__.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/form/__init__.py:1.4	Fri May  7 15:33:31 2004
+++ Zope3/src/zope/app/form/__init__.py	Tue May 11 07:11:52 2004
@@ -17,13 +17,13 @@
 import traceback
 from warnings import warn
 from zope.app import zapi
-from zope.app.form.interfaces import IWidget
+from zope.app.form.interfaces import IWidget, WidgetInputError
 from zope.component.interfaces import IViewFactory
 from zope.interface import implements
 from zope.i18n import translate
 
 class Widget(object):
-    """Mixin class providing functionality common accross view types."""
+    """Mixin class providing functionality common across widget types."""
     
     implements(IWidget)
 
@@ -64,6 +64,19 @@
 
     def setRenderedValue(self, value):
         self._data = value
+        
+class InputWidget(Widget):
+    """Mixin class providing some default input widget methods."""
+    
+    def hasValidInput(self):
+        try:
+            self.validate()
+            return True
+        except WidgetInputError:
+            return False
+
+    def validate(self):
+        self.getInputValue()
 
 class CustomWidgetFactory(object):
     """Custom Widget Factory."""




More information about the Zope3-Checkins mailing list