Am 12.05.2010 12:26, schrieb Haron Media:
- error message types are overwhelming, I want single error message per
field, meaning I have to set them all to same string, per field, per form.
- error messages are automatically prepended with field var name which
is ugly in itself, so it is meant to be parsed by HTMLFill

Actually I think you mix quite some different items (decorators, validation, html generation) as others already pointed out. However I really like the design that formencode shows you all errors at once (it's easy to show only one error message).

However I personally found FormEncode lacking in some areas (consistency, i18n, easily understandable API) even after writing dozens of validators myself. Therefore you might want to have a look at a small formencode-like library ('pycerberus') I wrote [1] which solves these issues for me. It's also easy to get just one error from a schema validation exception in this library... ;-)

And pycerberus is definitely not built for forms only - I use it in a SMTP server to validate all SMTP commandds.

Also such a class can be extended to automatically take model data on
input and have helper methods to build forms, already containing data,
so no HTMLFill is required (which, btw, I find rather clumsy, in parsing
HTML to change the form...). Aditionally, the SimpleForm class stores
data in session in case of failure, and can pick it up in next request,
so "traditional" forms can use redirect to avoid post back problem, and
the form class with automatically figure out that it has data in the
session, overriding any data passed from the model.

If that works for you personally, I'm fine with it. However I see a couple of problems: 1. I try to avoid using session data ('state') by all means. Basically your user can not post to two forms at the same time. 2. Coupling validation with model objects does not work for me - usually I have extra restrictions for end users but internal staff can do way more. 3. I'd like to have validation rules (validators) also separate from views so I can re-use these rules (not the composition aka a form/schema) in a JSON API or something similar.

If you want to see the nice things about formencode and pycerberus, you might want to read the first two paragraphs on [1] where I put up a bullet point list of pycerberus' strengths.

fs

[1] http://www.schwarz.eu/opensource/projects/pycerberus

--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to