A developer dealing with Deform has to understand a few fundamental types of objects and their relationships to one another. These types are:
- schema nodes
- field objects
The Relationship Between Widgets, Fields, and Schema Objects¶
The relationship between widgets, fields, and schema node objects is as follows:
- A schema is created by a developer. It is a collection of schema node objects.
- When a root schema node is passed to the
deform.Formconstructor, the result is a field object. For each node defined by the developer in the schema recursively, a corresponding field is created.
- Each field in the resulting field tree has a default widget type.
widgetattribute of a field object is not set directly by the developer, a property is used to create an instance of the default widget type when
field.widgetis first requested. Sane defaults for each schema type typically exist; if a sane default cannot be found, the
deform.widget.TextInputWidgetwidget is used.
The Colander documentation is a resource useful to Deform developers. In particular, it details how a schema is created and used. Deform schemas are Colander schemas. The Colander documentation about how they work applies to creating Deform schemas as well.
A widget is related to one or more schema node type objects.
For example, a notional “TextInputWidget” may be responsible for
serializing textual data related to a schema node which has
colander.String as its type into a text input control, while
a notional “MappingWidget” might be responsible for serializing a
colander.Mapping object into a sequence of controls. In both
cases, the data type being serialized is related to the schema node
type to which the widget is related.
field object (``field``) | | |----- widget object (``field.widget``) | | \----- schema node object (``field.schema``)