Discussion:
[FE-discuss] Validation as WSGI middleware: good or bad idea?
Matthew Wilson
2008-11-27 16:06:51 UTC
Permalink
Maybe it is because I am just beginning to understand how to use WSGI
middleware, but I have been daydreaming about moving validation into
the middleware layer, rather than something that happens further
downstream.

This might be useful if I want to hop to a completely different block
of code when validation fails. It might make really common validators
less obtrusive.

All comments are welcome -- am looking for feedback.

Matt
--
Matthew Wilson
***@tplus1.com
http://tplus1.com
Ian Bicking
2008-12-01 19:53:47 UTC
Permalink
Post by Matthew Wilson
Maybe it is because I am just beginning to understand how to use WSGI
middleware, but I have been daydreaming about moving validation into
the middleware layer, rather than something that happens further
downstream.
This might be useful if I want to hop to a completely different block
of code when validation fails. It might make really common validators
less obtrusive.
All comments are welcome -- am looking for feedback.
I think this is possible, but could easily turn into something too
complex and hard to modify. You'd have to wrap the middleware around
very specific WSGI apps (i.e., and app that just displays one form --
which might describe something like a single Pylons Controller) and then
handle all the possible errors from within the FormEncode validators.
SimpleFormValidator might make this somewhat clearer, but I'd still
expect this to be challenging.

Interestingly, though, you could do things like add validation to static
HTML forms, PHP apps, etc.
--
Ian Bicking : ***@colorstudy.com : http://blog.ianbicking.org
Loading...