Pyramid and MVC (split from: Re: Added Python, WSGI to XAMPP)
Gerry Reno
greno at verizon.net
Wed Dec 15 17:28:56 EST 2010
On 12/15/2010 05:03 PM, Chris Withers wrote:
> On 14/12/2010 00:58, Gerry Reno wrote:
>> What I really don't like right off is that Pyramid is contorting the MVC
>> model
>
> That specific pattern, I'm afraid, is a little antiquated nowadays,
> particularly when it comes to web apps...
>
>> The VIEW is the bits that stream out of the webserver back to the users
>> browser.
>
> Yep, and in Pyramid I guess this would be the template renderer, which
> is usually a decorator on the view function or class. The view's job
> is to process a request and turn it into a response dictionary. That
> sounds a lot like your controller to me ;-)
>
>> The CONTROLLER is the code that gathers all the pieces from
>> the model and constructs the python code
>
> Slightly scared as to what "constructed the python code" might mean :-S
>
>> that is then fed to the engine
>> that then creates the view. And just because the controller navigates
>> the logic to dynamically contruct/render a view, that does not make 'it'
>> the view.
>
> Well, for me, the MVC isn't really what happens anymore, here's my take:
>
> - the model nowadays has all the "business logic" in it, rather than
> just the data. The model is now a collection of objects that can be
> interacted on through many/any UIs needed, some of which may be web apps.
>
> - web apps are *always* a collection of request/response transactions.
> As such, the "control" layer does just become a "view" that does that.
>
> - singleton objects and other stuff that used to live in a "control"
> are now factored out into utilities and services (of which
> zope.component provides a pretty good abstraction, and doesn't really
> have anything to do with Zope, other than the fact that Zope makes use
> of it).
>
> Welcome to the 2nd decade in the new millenium ;-)
>
> Chris
>
It doesn't matter whether you are building a desktop app or a webapp.
MVC still applies. And that includes when things like Ajax are added to
the mix because Ajax just performs a mini-MVC transaction. The problems
arise when people start rigidly thinking that M only meant database. M
means model, model means any source that emits data. A database,
another webapp, whatever, that is M. The view as I said before is just
the bits streaming out of the webserver back to the client device.
There should be NOTHING on the server call view-anything. The view only
exists on the clients. The view is the result of what the
controllers(servers) in conjunction with renderers emit as their work
product.
-Gerry
More information about the Python-list
mailing list