[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/src/zope/schema -_bootstrapfields.py:1.19.2.1

Garrett Smith garrett@mojave-corp.com
Tue, 22 Jul 2003 10:27:53 -0500


Steve Alexander wrote:
>> setData()
>>     Set the initial value of the widget for it's initial display.
>>     When a form is re-rendered due to a "partial submit", this value
>>     is ignored, and the value from the request is used instead.  This
>>     requires *really* knowing what the value was on the browser when
>>     the submit button was pressed---even if it was an empty string.
>=20
> Related to this, I want to be able to set up a widget with
> erroneous/missing data, so that on first viewing a page, I can have it
> rendered as if that same data had been present in the request.

This is the way things work in my branch. E.g. enter 'foo' in an integer
field -- the widget will continue to render 'foo' along with a
conversion error msg.

>  > Changing the
>> get/have/setData() behavior needs very careful review.  The effects
>> to code will spread well beyond the Zope 3 core, and not just in Zope
>> Corporation projects.
>=20
> It'll certainly break my code :-)

How?

There were a number of unit tests that failed because they were
asserting that their missing values where not present -- i.e. hasData()
=3D=3D False.

setData is called judiciously to avoid overwriting values from the form.
But, as Fred mentioned, setData should probably not override form values
anyway.

The fact that getData does not raise an error when a value is 'missing',
hopefully, won't cause too many problems. The validation for required
fields occurs in applyChanges.

 -- Garrett