[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - field.py:1.11.8.1

Garrett Smith garrett@mojave-corp.com
Tue, 22 Jul 2003 09:01:20 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv26193/src/zope/app/browser/services

Modified Files:
      Tag: garrett-widgets-branch
	field.py 
Log Message:
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS: 
CVS: Committing in .
CVS: 
CVS: Modified Files:
CVS:  Tag: garrett-widgets-branch
CVS: 	src/zope/app/browser/cache/cacheable.py 
CVS: 	src/zope/app/browser/component/interfacewidget.py 
CVS: 	src/zope/app/browser/component/tests/test_interfacewidget.py 
CVS: 	src/zope/app/browser/form/editview.py 
CVS: 	src/zope/app/browser/form/vocabularywidget.py 
CVS: 	src/zope/app/browser/form/widget.py 
CVS: 	src/zope/app/browser/form/tests/test_browserwidget.py 
CVS: 	src/zope/app/browser/form/tests/test_checkboxwidget.py 
CVS: 	src/zope/app/browser/form/tests/test_datetimewidget.py 
CVS: 	src/zope/app/browser/form/tests/test_editview.py 
CVS: 	src/zope/app/browser/form/tests/test_floatwidget.py 
CVS: 	src/zope/app/browser/form/tests/test_intwidget.py 
CVS: 	src/zope/app/browser/form/tests/test_objectwidget.py 
CVS: 	src/zope/app/browser/form/tests/test_sequencewidget.py 
CVS: 	src/zope/app/browser/form/tests/test_vocabularywidget.py 
CVS: 	src/zope/app/browser/security/permissionwidget.py 
CVS: 	src/zope/app/browser/services/field.py 
CVS: 	src/zope/app/browser/services/registration/__init__.py 
CVS: 	src/zope/app/browser/services/tests/test_field_widget.py 
CVS: 	src/zope/app/browser/skins/rotterdam/editingwidgets.py 
CVS: 	src/zope/app/dav/configure.zcml src/zope/app/dav/widget.py 
CVS: 	src/zope/app/form/utility.py src/zope/app/form/widget.py 
CVS: 	src/zope/app/form/tests/test_utility.py 
CVS: 	src/zope/app/form/tests/test_widget_geddon_deprecations.py 
CVS: 	src/zope/app/interfaces/form.py 
CVS: 	src/zope/schema/_bootstrapfields.py 
CVS: ----------------------------------------------------------------------
Several changes related to widgets:

- Changed haveData to hasData.

- Propogated the use of Field.missing_value as an alternative to
  explicit checks for None and '' (empty string).

- Changed the default implementation of hasData (was haveData) to return
  True only if the one of the following was true:

  - setData had been called for the widget. Per IWidget, values passed to
    setData override all other data sources for a widget.

  - There is a value in the request form that corresponds to the widget
    field.

  Prior to this change, hasData would return False if the widget's data
  equaled the field's missing value. E.g., a text widget with an empty
  string would return False, indicating that it has no data, even though
  the empty string, a legitmate value, was submitted in the request.

  This change required a handful of other changes to reflect the new
  logic.

  The bulk of this change effected widget.py. To see how the new logic
  implementation of hasData effected widgets, see test_browserwidget.py
  and test_utility.py.

- Modified the update logic for objects to skip fields that are not
  present in the request form. Prior to this change, unspecified values
  (i.e. values not in the request form) would cause default values to be
  set for corresponding object fields.

- Exposed missing_value in initializer for Field - developers can now
  specify a missing value for a schema field.

- Changed the default implementation of field validation. Prior to this
  change, validation failed if a required value was missing. Now validation 
  is limited to validating non-missing values and the check for required
  values is performed elsewhere.

- Text fields have a missing_value of '' (empty string) instead of None.

- Widget related error classes have been revamped:

  - WidgetInputError, the base class for all widget related errors, now
    provides two attributes: widget, the widget associated with the
    error, and error_msg, a string describing the error,

  - WidgetInputError implements 'args' so it can be rendered like other
    errors.

  - MissingInputError uses a standard error message.

  - All uses of WidgetInputError and its subclasses have been updated
    to use the new class.

- Deleted class zope.app.browser.form.widget.PossiblyEmptyMeansMissing.
  This capability is now handled by setting a field's missing_value to '' 
  (empty string).

- Changed widget's _showData:

  - Renamed to getUnconvertedData to clarify the method meaning and signal
    its use as a public method.

  - Positioned the method as a complement to getData, which returns data
    in its converted form. getUnconvertedData returns data in its
    unconvereted form using _unconvert.

- Renamed the 'force' argument used in various setUpWidget methods in 
  utility.py to 'ignore_unspecified'. This argument is set to True to
  ensure that fields that are not in a form are not used to update their
  corresponding widget. This argument should be true during object
  updates (see editview.py) to ensure that unspecified fields are not
  updated.

- Removed the 'strict' argument from applyWidgetChanges since no one was
  using it and there's no clear application for it.
  



=== Zope3/src/zope/app/browser/services/field.py 1.11 => 1.11.8.1 ===
--- Zope3/src/zope/app/browser/services/field.py:1.11	Mon Jun 30 12:23:33 2003
+++ Zope3/src/zope/app/browser/services/field.py	Tue Jul 22 09:00:45 2003
@@ -23,24 +23,23 @@
 from zope.app.form.widget import Widget
 from zope.publisher.browser import BrowserView
 from xml.sax.saxutils import quoteattr
-from zope.app.interfaces.form import WidgetInputError
 from zope.app.traversing import traverse, canonicalPath
 from zope.interface import implements
 
 class ComponentPathWidget(BrowserWidget):
 
-    def haveData(self):
+    def hasData(self):
         value = self.request.form.get(self.name, None)
         if not value:
             return False
         else:
-            return super(ComponentPathWidget, self).haveData()
+            return super(ComponentPathWidget, self).hasData()
 
     def _convert(self, value):
         return value or None
 
     def __call__(self):
-        selected = self._showData()
+        selected = self.getUnconvertedData()
         field = self.context
         return renderPathSelect(field.context, field.type,
                                 self.name, selected)
@@ -48,7 +47,7 @@
 class ComponentPathDisplayWidget(ComponentPathWidget):
 
     def __call__(self):
-        path = self._showData()
+        path = self.getUnconvertedData()
         path = canonicalPath(path)
         ob = traverse(self.context.context, path)
         url = str(getView(ob, 'absolute_url', self.request))