[Zope3-checkins] CVS: Zope3/src/zope/app/browser/component/tests - test_interfacewidget.py:1.23.18.1
Garrett Smith
garrett@mojave-corp.com
Tue, 22 Jul 2003 09:01:36 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/component/tests
In directory cvs.zope.org:/tmp/cvs-serv26193/src/zope/app/browser/component/tests
Modified Files:
Tag: garrett-widgets-branch
test_interfacewidget.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/component/tests/test_interfacewidget.py 1.23 => 1.23.18.1 ===
--- Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py:1.23 Tue May 13 13:08:33 2003
+++ Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py Tue Jul 22 09:00:30 2003
@@ -74,7 +74,7 @@
widget = InterfaceWidget(field, request)
self.assertEqual(widget.getData(), None)
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
out = (
'<input type="text" name="field.TestName.search" value="">'
@@ -131,7 +131,7 @@
)
self.assertEqual(widget.getData(), None)
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
widget = InterfaceWidget(field, request)
@@ -139,7 +139,7 @@
'zope.app.browser.component.tests.test_interfacewidget.I2'
)
self.assertEqual(widget.getData(), I2)
- self.failUnless(widget.haveData())
+ self.failUnless(widget.hasData())
out = (
'<input type="text" name="field.TestName.search" value="">'
@@ -196,7 +196,7 @@
widget = InterfaceWidget(field, request)
self.assertEqual(widget.getData(), None)
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
out = (
'<input type="text" name="field.TestName.search" value="">'
@@ -229,7 +229,7 @@
widget = InterfaceWidget(field, request)
self.assertEqual(widget.getData(), None)
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
out = (
'<input type="text" name="field.TestName.search" value="">'
@@ -269,7 +269,7 @@
'None'
)
self.assertEqual(widget.getData(), None)
- self.failUnless(widget.haveData())
+ self.failUnless(widget.hasData())
out = (
'<input type="text" name="field.TestName.search" value="">'
@@ -397,7 +397,7 @@
widget = MultiInterfaceWidget(field, request)
self.assertEqual(widget.getData(), ())
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
out = (
'Use refresh to enter more interfaces'
@@ -452,7 +452,7 @@
'</select>'
)
self.assertEqual(widget(), out)
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
widget = MultiInterfaceWidget(field, request)
@@ -460,7 +460,7 @@
'zope.app.browser.component.tests.test_interfacewidget.I2'
)
self.assertEqual(widget.getData(), (I2,))
- self.failUnless(widget.haveData())
+ self.failUnless(widget.hasData())
out = (
'Use refresh to enter more interfaces'
'<br />'
@@ -512,7 +512,7 @@
'</select>'
)
self.assertEqual(widget(), out)
- self.failUnless(widget.haveData())
+ self.failUnless(widget.hasData())
# There is no selected option because the option that would be
# selected has been filtered out by the search.
@@ -559,7 +559,7 @@
'</select>'
)
self.assertEqual(widget(), out)
- self.failUnless(widget.haveData())
+ self.failUnless(widget.hasData())
label = '<label for="field.TestName">This is a test</label>'
self.assertEqual(widget.label(), label)
self.assertEqual(widget.row(),
@@ -575,7 +575,7 @@
widget = MultiInterfaceWidget(field, request)
self.assertEqual(widget.getData(), ())
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
out = (
'Use refresh to enter more interfaces'
@@ -643,7 +643,7 @@
request.form["field.TestName.i1"] = 'None'
self.assertEqual(widget.getData(), (None,))
- self.failUnless(widget.haveData())
+ self.failUnless(widget.hasData())
out = (
'Use refresh to enter more interfaces'
@@ -832,14 +832,14 @@
widget = MultiInterfaceWidget(field, request)
self.assertEqual(widget.getData(), ())
- self.failIf(widget.haveData())
+ self.failIf(widget.hasData())
request.form["field.TestName.i1"] = (
'zope.app.browser.component.tests.test_interfacewidget.I2'
)
request.form["field.TestName.i0"] = ''
self.assertEqual(widget.getData(), (I2,))
- self.failUnless(widget.haveData())
+ self.failUnless(widget.hasData())
class TestRenderInterfaceSelect(TestCase):