[Zope3-dev] default and required analysis
Jim Fulton
jim@zope.com
Thu, 09 Jan 2003 10:41:06 -0500
Based on Martijn's analysis and Steve's comments, I proposed the following:
- If a field is in the schema, objects that implement the schema must
have a corresponding property implementing the field.
- If a field is required, then all values of properties implementing the field
must satisfy the field's constraints.
- If a field is not required, then a property implementing a field may have a
field-defined missing value that does not satisfy the field's constraints.
The default missing value will be None, but fields may provide different missing
values.
- Fields may define default values. An application (like a form) can use this
default value to provide a value when a value is needed and no other value is
available. The default value may be the field-defined missing value or
a value that satisfies the field's constraints.
If a field is required and the default value does not satisfy the field's
constraints, then the default value cannot be used to provide a value for a
property implementing the field.
Note that, when collecting user input, you usually need to know if a user
specified anything. How you do this need not have anything to do with the
field definition.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org