[Zope3-dev] Schema, widget and form refactoring (was Re: [Zope3-checkins]CVS:Zope3/src/zope/schema - _bootstrapfields.py:1.19.2.1)

andre borelan@wanadoo.fr
Wed, 23 Jul 2003 11:53:04 -0400


Garrett Smith a écrit:

 >   <field type="string" value="" />
the value is "", a string

 >   <field type="string" value="None" />  <!-- doh! -->
the value is "None", a string.
In your example, how is this value passed to the data structure ?
Is it Html or did you mean something else ?

After having read a little about utility.py and widget.py, and in the 
state of my knowledge,

- it seems to me that the expression missing_value is ambiguous.
   value_if_missing will be better (IMO).
- it seems necessary to have a clear definition of the words used.
   (missing, required, default, None, etc.)

Required : not empty
Missing  : empty but not required
Default  : The starting value of a field. Must be kept until the user or
            a function, changes its value.
            May become Missing
None     : Nothing
''       : empty string if not Required
            None if Required
0        : value 0 if Required
          : None if not Required

the case 'not_empty_but_not _conform is managed by a validation process 
in the function, action or whatever program using the data structure, as 
usual.

	
what do you think about a mapping :

if_missing={'field_name_1': None,
             'field_name_n':'None}

 > Btw, the folks who expect None as their missing value will be happy
 > 100% of the time -- it's the default.

I don't know where it should be set but if it's the schema,
when building the schema if_missing is initialized as above.
None_fans would be happy and they'd have nothing to do.
None_antis would be happy too as they'd be able to explicitly define the 
*replacement* value of a missing field.

and we'd have :
         elif set_missing:
             result[name] = schema.if_missing[name]
instead of :
             result[name] = None # XXX field.missing_value

there's another way:
when building schema
if_missing={}

in getWidgetsData,
         elif set_missing:
             result[name] = schema.if_missing.get(name, None)


As i'm just beginning to dive into Zope3 i let you estimate the value of 
  the above.
If it's stupid, please, let me know why.

Andre