[Zope3-dev] Schema Converters

Martijn Faassen faassen@vet.uu.nl
Mon, 15 Jul 2002 11:37:54 +0200


Stephan Richter wrote:
> I think that converters shoudl convert from Field to Field and not map Python 
> types. This way it will be much more flexible.

I do not understand; the input will not yet conform to any field but just a
python value such as a string (say as a result of browser form submits).
The point of converters + validators is to make sure this value conforms to
a particular field in a schema.

So, it looks like this in my mind:

     form submit
          |
   value foo (string) in request
          |
   StrToIntConverter  -> ConversionError
          |
      value foo (int)
          |
    IntValidator (with extra constraints such as range) -> ValidationError
          |
      value foo (int) (unchanged)
 
where form submit, StrToIntConverter are part of a BrowserView (in this
case) and the IntValidator is part of the content (or an adapter).

This picture can become more complicated as Converters may actually use
small schema themselves. For instance a DateTimeConverter may use a
schema of three int fields, for day, month, year and also a bunch of
StrToIntConverters to convert browser input. ConversionErrors should then
contain enough information so that the developer can display what went
wrong in detail (month out of range, month 13 does not exist).

How does mapping from Field to Field come in here?

Regards,

Martijn