On Mon, Apr 5, 2010 at 6:36 AM, Tim Black <[email protected]> wrote:
> cd34 wrote:
>
> While the controller at that point would have 4-5 lines of code before
> the response, considering that action is only used once and it isn't
> duplicating code used elsewhere, all I would really be doing is moving
> code from one place to another.
>
> I'm beginning to think that when I write controllers named things like
> getTaskHTML() or setTaskHTML() when I have a model.Task object but it
> doesn't have an attribute named HTML, I should refactor those methods to
> this form:  model.Task.HTML where HTML is a Python property or is accessible
> via __setattr__ and __getattribute__.  In general, if I'm writing controller
> methods that are merely basic manipulations of model objects, I'm thinking I
> should put those methods into the model rather than the controller.  Is that
> correct?

Philosophically, the model shouldn't have any  structural (WSGI- or
HTTP-specific) or UI (HTML-specific)  code in it.  The input values
are coming from POST parameters, which the model shouldn't know about.
 The model should make sense outside a web context.  So there should
be at least a thin layer validating/translating the input to generic
arguments.

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