Marco Mariani wrote: > Adam Jones wrote: > >> 3 - always write a form validator; have it "mess" with the DB and check > >> everything is in place, maybe doing half the work of the save() > >> method... not its job, I guess > >> > > > > I actually like this solution. > I'm unsure. Do people usually validate a form by taking all of the > context into account? Or is a validator, after all, only interested the > relationship between the form data?
I think I am probably in the minority on this opinion. Most people probably like a stricter separation between form validation and environment checking for the data. My understanding is that the typical requirements for form validation are that the data meets certain parameters (presence, content/structure restrictions, etc). My preference would be to be able to write my controllers under the assumption that all of the data they are working with is valid and ready to be manipulated without any additional checking. It makes them a lot simpler. In practice, though, that often creates a race condition at any mutable resource after validation but before the controller makes its changes. I actually didn't think about this until just now, so I am glad we are having this discussion. Luckily the stuff that I am working on involves multiple users each having their own data, so there is no risk of anyone stepping on someone else's information. -Adam --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears -~----------~----~----~----~------~----~------~--~---

