[Zope3-Users] Fwd: Validation of viewlets in forms?

Paul Carduner paulcarduner at gmail.com
Fri May 30 12:39:33 EDT 2008


On Wed, May 28, 2008 at 12:34 PM, Paul Winkler <slinkp at gmail.com> wrote:
> (whoops, i accidentally sent this to zope3-dev; re-sending.)
>
> I'm wondering what's a nice way to deal with (server-side) validation
> of a form composed of multiple viewlets.
> I don't think I really want to move to a full-featured forms framework
> yet, they all seem a little overly complex to me.
>
> In the viewlet code, the obvious thing to do would be to raise an
> exception in its update() method if there's a problem, otherwise save
> the data or whatever.
> This is what Philip does in his worldcookery viewlet examples.
>
> But this means you only ever see the first error. In order to show the
> user *all* the validation errors at once, something (the viewlet
> manager?) would have to catch those exceptions.
> And having done that, we would need to explicitly abort the
> transaction. I'm not sure the best place to do that.
>
> I could just poke around until I get something working, but I was
> hoping somebody here would already have a nice example I can look at.
> Should I just get used to the idea of using z3c.form or some such?

I would just get used to the idea of using z3c.form.  It will be
especially helpful to look at z3c.formdemo, which has examples that I
think are highly relevant to your usecase.  You'll end up writing a
less code that does more.

-- 
Paul Carduner
http://www.carduner.net


More information about the Zope3-users mailing list