[Zope3-checkins] SVN: Zope3/trunk/ - small refactoring in widget internal code (support getting the current

Christian Theune ct at gocept.com
Fri Sep 22 05:31:38 EDT 2006


Log message for revision 70331:
   - small refactoring in widget internal code (support getting the current
     value, not only the current form representation of the value)
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/form/browser/widget.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-09-22 07:52:15 UTC (rev 70330)
+++ Zope3/trunk/doc/CHANGES.txt	2006-09-22 09:31:36 UTC (rev 70331)
@@ -59,6 +59,10 @@
 
     Restructuring
 
+      - Changed internal widget API to allow retrieving the current value
+        (from request, default or current field value) in addition to the
+        current form representation of the value.
+
       - Refactored zope.decorator into zope.proxy.decorator and
         zope.security.decorator.
 

Modified: Zope3/trunk/src/zope/app/form/browser/widget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/widget.py	2006-09-22 07:52:15 UTC (rev 70330)
+++ Zope3/trunk/src/zope/app/form/browser/widget.py	2006-09-22 09:31:36 UTC (rev 70331)
@@ -352,8 +352,11 @@
         else:
             return value
 
-    def _getFormValue(self):
-        """Returns a value suitable for use in an HTML form."""
+    def _getCurrentValue(self):
+        """Detects the status of the widget and selectes either 
+        the input value that came from the request, the value from the 
+        _data attribute or the default value.
+        """
         if not self._renderedValueSet():
             if self.hasInput():
 
@@ -373,6 +376,11 @@
                 value = self._getDefault()
         else:
             value = self._data
+        return value
+
+    def _getFormValue(self):
+        """Returns a value suitable for use in an HTML form."""
+        value = self._getCurrentValue()
         return self._toFormValue(value)
 
     def _getDefault(self):



More information about the Zope3-Checkins mailing list