On Wed, Jun 6, 2012 at 3:06 PM, Vlad K. <[email protected]> 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 <[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.

Reply via email to