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

Garrett Smith garrett at mojave-corp.com
Wed Aug 13 18:28:46 EDT 2003


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

Modified Files:
	form.py 
Log Message:
Made the following changes to the widget machinery:

- Renamed IWidget getData to getInputValue

getInputValue no longer accepts an 'optional' flag. If value is missing or is invalid, getInputValue will raise an error. Calls made to this method should be in a try...except block to handle such conditions.

- Renamed IWidget haveData to hasInput

- Added method hasValidInput to IWidget and widget implementations

- Renamed IWidget setData to setRenderedValue

- Added functional tests for some of the core widgets - additional ftests are needed

- Deleted the class PossibleEmptyMeansMissing - it's no longer needed

- Added deprecation tests for changes to widgets

- Some widgets were refactored to use the new framework correctly

These changes were based on the proposal:

 http://dev.zope.org/Zope3/ComponentArchitecture/WidgetsFormsSchemas

Not all the changes in the proposal are included in this commit. Specifically, getRawData/setRawData and the refactoring of the widget error classes are the two major changes not included in this commit.

=== Zope3/src/zope/app/interfaces/form.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/interfaces/form.py:1.6	Thu Aug  7 17:34:49 2003
+++ Zope3/src/zope/app/interfaces/form.py	Wed Aug 13 17:28:42 2003
@@ -112,8 +112,11 @@
         errors encountered, inputting, converting, or validating the data.
         """
 
-    def getData():
-        """Return converted and validated widget data.
+    def getInputValue():
+        """Return value suitable for the widget's field.
+
+        The widget must return a value that can be legally assigned to 
+        its bound field or otherwise raise WidgetInputError.
 
         See validate() for validation performed.
         """
@@ -125,10 +128,27 @@
         """
 
 
-    def haveData():
-        """Is there input data for the field
+    def hasInput():
+        """Returns True if the widget has input.
+
+        Input is used by the widget to calculate an 'input value', which is
+        a value that can be legally assigned to a field.
+
+        Note that the widget may return True, indicating it has input, but
+        still be unable to return a value from getInputValue. Use
+        hasValidInput to determine whether or not getInputValue will return
+        a valid value.
+
+        A widget that does not have input should generally not be used to 
+        update its bound field.
+        """
+
+    def hasValidInput():
+        """Returns True is the widget has valid input.
 
-        Return True if there is data and False otherwise.
+        This method is similar to hasInput but it also confirms that the
+        input provided by the user can be converted to a valid field value
+        based on the field constraints.
         """
 
     name = Attribute("""The uniquewidget name
@@ -140,11 +160,10 @@
 
     required = Attribute("Flag indicating whether the field is required")
 
-    def setData(value):
-        """Set the default data for the widget.
+    def setRenderedValue(value):
+        """Set the value to be rendered by the widget.
 
-        The given value should be used even if the user has entered
-        data.
+        Calling this method will override any values provided by the user.
         """
 
     def setPrefix(prefix):




More information about the Zope3-Checkins mailing list