Hello all,

I stepped upon Colander a few days ago in PyPI, and I like it's concept and
functionality. I have developed something very similar for internal use in
my company, not as polished however.

But I think a key functionality is missing from Colander: mapping between
user interface control and data model. Suppose your data comes from a web
form, and you have a series of repeated fields that map to the same logical
field in your deserialized data, and you want to validate, then show
possible errors back to the user. You'll have the field names and message
errors. Ex:

Data model:

  <name>Steve Howe</name>
    <street>Av. X</street>
    <street>Av. Y</street>

...e so forth.

Form model:


If number for second <address> is wrong, Colander would report something
like this:

Invalid: {'number': 'Number is invalid'}

In the case of a detected error, how do you plan to report that back to the
user interface (i.e. the web form)? As you can see, there's no simple way to
map form.address[0].number <-> address1.number.

In my mentioned internal validation framework, I send a dictionary to the
server, such as {'field': 'address', 'value': 'Av. X', 'id': 'street2'} (id
being the form control "name" property) and thus I'll keep a reference to
the original source the data came from. Being a dictionary, it's extensible
in case I need to send even more data (then just "name", "value") to the
server .

How do you deal with this kind of situation ?


Steve Howe

Repoze-dev mailing list

Reply via email to