thanks eric.

that is what i'm talking about!

i've got my version working with formencode.  in addition to the gist
above, i decided to just go ahead and set up
pyramid_formencode_classic on pypi and github   (
https://github.com/jvanasco/pyramid_formencode_classic )

if i have some time this weekend, i'll try to see if I can switch to
deform.  while I like formencode and the methods i've been using, i
really dislike how it relies on regexing to 'htmlfill' an invalid
form.  i'd rather have a "render" method , and i think deform lets you
render fields individually (so you can control layout )

i use a similar concept as you.  i have the form logic separated into
3 methods that essentially do the same as your if/else with a try.
- public dispatcher
- private form render
- private form submit

the dispatcher calls the render method by default. if it decides to
submit, I note the errors in a 'wrapper' for the formencode object,
then raise an exception to catch the form and reprint.  this was
basically an approach I ended up with on pylons, as the easiest way to
manage formencode stuff.

I'm in total agreement that this general approach ( whether 1 action
or 3 ) is considerably easier to handle forms with than many of the
other approaches out there.

i made a quick diff (https://gist.github.com/1776061) with a few
suggestions:

added kwargs on init
-- submit_autodetect=True
-- render_state=None
-- params_source='POST'
it preserves your functionality, but allows the 'render first' or
other to be explicitly called, you can also validate on 'GET'


this may not even be necessary, but on init i also set
self.cstruct=None, and changed the cstruct to save there on
deserialize...  i figured that on advanced forms you might want to
render fields individually.. and while i didn't dive into making a
wrapped function to render a specific element yet... that data needs
to be stashed somewhere.

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

Reply via email to