On Fri, Oct 23, 2009 at 3:29 PM, Kevin J. Smith <[email protected]> wrote: > I'm curious as to what everyone's hate for @validate is. I have been a long > time user of FormEncode and new to Pylons and found @validate pretty damn > slick. I've got custom validators and chained validators and never really > had a complaint. I've definitely ran into situations that have me > scratching head as to how I am going to get it to work but there always > seems to be a way and it ends up being reasonably elegant with FormEncode.
The decorator works, it's just limited. Ideally you want to do all your validation the same way. But @validate can only handle some cases. 1. If you want to validate based on the current database record, that isn't known until the middle of the action. This would be a good use for 'state', but there's no way to pass state through the decorator. 2. The default post_only=True, on_get=False is ridiculous. It ends up passing GET requests through without validation, which will then cause your action to crash (if expected data isn't there or is the wrong type) or to perform an action it shouldn't. 3. If the validation passes but you later want to flag a different error, you're in the same situation the OP is in. 4. If you want to perform some of the error handling in the action, you can't just paste code from @validate because it does a lot of other stuff to deal with its arguments, and you have to sit there and think about which parts of the code are relevant to the situation and how to transform them. -- Mike Orr <[email protected]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
