[Zope3-dev] bug setting value to None via edit form
Garrett Smith
garrett@mojave-corp.com
Sat, 12 Jul 2003 16:52:57 -0500
Steve Alexander wrote:
>> The value passed to setUpWidget is already converted to its Python
>> form at this point. So, in my example, IntWidget already converted
>> the empty string in the HTTP form to None.
>>=20
>> Having read over Martijn's use cases, I don't think field's have
>> 'missing_value' attributes
>=20
> Right. They don't yet. They should be made to do so.
>=20
>=20
>> -- an attribute that's missing has a None value,
>=20
> Yes. And this doesn't work when None is a legitimate value for your
> attribute.
Gotcha -- I was negligent and hadn't read the last link :-)
I think the approach you're taking is pretty esotheric. I'd like to see
some use cases for making anything other than None a 'missing' value. If
a value is None, I'd say it's missing. If that's a legtimate value, then
the field's not required.
Default values can be handled explicitly -- e.g.
field.setDefaultValue(), or field.set(field.default). Personally, I
cringe at this:
def grok(alpha, beta, gamma=3DNone):
if gamma is None:
gamma =3D 4711 # default value for gamma
and would spell it:
def grok(alpha, beta, gamma=3D4711):
if grok is None:
# maybe complain here?
I.e. if I set something to None, I expect it to stay None, else raise an
error...at least in the case of setting field values.
I suspect we'll end up seeing field.missing_value =3D None in every =
case,
with perhaps some very funky exceptions.
I also suspect I stand to be corrected in a moment ;-)
-- Garrett