Hello,

I am not very happy with the default validation scheme suggested by Pylons
and trying to design my own.

The idea is to let the code handle main code path (data is valid) and handle
validation error separatedly. I want to be able to set validation_handler
which is then invoked by BaseController when validation fails.

E.g.

class SomeController(BaseController)
    def index(self):
        code = get_request_param('code', validator=...)
        # do something with validated parameter "code"
    index.validation_handler = lambda errors: Response('Oops!')

class BaseController(WSGIController):
    def __call__(self, environ, start_response):
        # ...
        try:
            return WSGIController.__call__(self, environ, start_response)
        except ValidationError, e:
            validation_handler = getattr(XXX, 'validation_handler', None) or
default_validation_handler
            return validation_handler(e)

I struggle to find the XXX object I can query to access the
validation_handler (such as the one defined for index()).

Any ideas?

Thanks,
Max.

--~--~---------~--~----~------------~-------~--~----~
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