[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 11:53:16 -0500
Fred L. Drake, Jr. wrote:
> -_bootstrapfields.py:1.19.2.1
>=20
>=20
>=20
> Garrett Smith writes:
> > I don't really like the fact that browser widgets read directly
> from the > form. I'd rather something configure the widgets
> explicitly with calls > like:
> >
> > setUserInput(value)
>=20
> What would you pass as value?
In all cases currently:
widget.request.form.get(widget.name, None)
This would be done during the setup phase.
> > Here, perhaps, we could state that passing a None value to this
> method > indicates that there 'is no user input'. And
> >
> > getUserInput() is None
> >
> > indicates the same.
>=20
> Is getUserInput() a widget method? If something else is providing the
> input input to the widget using setUserInput(), the widget wouldn't
> need to be involved in this. So I'm not sure what's going on here.
> Also, what is getUserInput() supposed to return?
The name is confusing, given the nature of widgets. It's the
read-accessor to 'userInput' -- it returns the value provided by
setUserInput.
Perhaps a better way to handle this would be through properties.
> > I also don't like the fact that widget has getValue and getData --
> these > are too similar and give no hint as to how they're
> different. I'd prefer > something like:
>=20
> I think getValue() can be removed. That appears to be there to
> support CustomWidget, but that doesn't use propertyNames or the
> non-existant setValue() method.
Ah, excellent. I would still be inclined to spell 'the value meant for
the field" as:
getFieldValue/setFieldValue
Perhaps setFieldValue could be 'overrideFieldValue' to signal what it's
doing, but I prefer setFieldValue with a note that it will override any
values derrived/converted from user input.
And, as long as I'm throwing out wish lists...
I think _conver and _unconvert should be made public and renamed to:
fieldValueToUserInput(value)
userInputToFieldValue(value)
to clarify what's going on.
-- Garrett