I have never used Colander either and will try it for the validations.  I 
have a LOT of db related validations so as Mike suggested I am trying to 
put them in the @classmethod.
Thanks for all the great replies.  It just takes a little bit getting used 
to not having multiple assemblies, but love the flexibility the framework 
allows.

Tanshu


On Thursday, June 7, 2012 11:12:30 PM UTC+5:30, Mike Orr wrote:
>
> On Wed, Jun 6, 2012 at 3:06 PM, Vlad K. wrote: 
> > On 06/06/2012 09:18 PM, Mike Orr wrote: 
> >> 
> >> I generally put business logic in the model, but I may have a 
> >> different notion of business logic than Tanshu does. To me, business 
> >> logic is any calculations that are specific to the model but are 
> >> *independent* of the UI and HTML. 
> > 
> > I'd argue that model data validation, which may be another way to call 
> form 
> > validation, belongs to the model. For that I use colander which is then 
> > agnostic of the input method (form, XML, JSON API, ...). If the 
> validator 
> > raises exceptions, then the view can handle them appropriately: 
> construct 
> > warnings, mark invalid fields, etc... which then clearly belongs to the 
> view 
> > and template. The same validators are then available to command line 
> scripts 
> > that reuse the models, cron tasks, ..., and it is even nicely 
> unit-testable. 
>
> I have not used Colander. It may be more viable for the model than 
> FormEncode is. 
> I just find that FormEncode gets too close to the UI (the HTML 
> representation of booleans, the way nested variables are flattened 
> into <input> IDs, etc) to be part of the model. I keep my validators 
> in a separate module distinct from either the model or views. 
>
> -- 
> Mike Orr
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pylons-discuss/-/DFo6Bp49_0IJ.
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