Python web development that resembles PHP or classic ASP

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue May 27 03:47:41 EDT 2008


erik.oosterwaal at gmail.com a écrit :
>> There are a couple points I don't get here. Mostly: how is your
>> application logic separated from the presentation logic if you "intermix
>> code directly into the HTML" ? Or are you pages including the libs,
>> getting the appropriate data out of the DB, and then including another
>> file acting as a template ? If so, then how are you're "pages" different
>> from MVC frameworks controllers ?
> 
> I have the WSC files as "libraries" I can open in a standard ASP page,
> So for example, to get a recordset in one of my ASP pages, I would use
> something like
> 
> 	Dim objUsers, Recordset_of_users
> 	Set objUsers= GetObject("script:" & Server.MapPath("/~components/
> users.wsc"))
> 		objUsers.open()
> 		Set Recordset_of_users =
> objUsers.getUsersByGroup(request.queryString("group_id"))
> 		objUsers.close()
> 	Set objUsers= Nothing
> 
> I put code like this at the top of my ASP pages, and inside the HTML
> code I can use "Recordset_of_users" and loop through it (for example).
> All code in the asp pages is getting and setting information, or
> looping through it. All real (business) logic is inside the WSC files.

> The only real difference is that I don't use the "C" of MVC.

Yes you do. It's exactly what your code snippet above is : a controller. 
   Or at least the same part of the controller that we identify as such 
in web MVC frameworks (the web server and request to handlers mechanism 
being the other, less visible but still present part). Having the 
controller's code mixed up with the view is pretty common in GUI 
toolkits, and not so uncommon in "server pages" frameworks.


> I dislike
> a controller that calls and routes functionality based on the URL.

Oh yes ? And how is it so different from having the web server routing 
to requests to .asp files calls based on a url-filesystem mapping ?-) 
Except, of course, that getting rid of the filesystem mapping decouples 
the app's urls scheme from the source code inner organisation ?

> The
> M (model) functionality is covered by the WSC files. The V (view) are
> the asp pages themselves. The controller part is handled by the asp
> pages aswell, just using regular links, GETs and POSTs in forms.
> 
>> But, IMHO, writing PHP-style Python webapp is silly.
> 
> :) Maybe I need to pick up a new style of programming as well, on top
> of just a new language...

Given your above explanations, I don't think going the "full" MVC route 
would require that much changes to your current habits. That is mostly: 
splitting the controller part from the view part, and learn to declare 
your url mapping instead of physically structuring your source depending 
on the url scheme.

>> Better shoot yourself in the foot with a PHP-like Python-thing, than
>> committing suicide by shooting yourself into the head with PHP ...
> 
> LOL, point taken.
> 
> So to summarize: it should be possible to get exactly what I want, but
> it's not advisable, because the frameworks aren't designed to work
> like this. That makes sense.
> I want to thank you guys for all the advice, I have a lot of
> frameworks and template-engines to look into now, I'll have a look at
> all that you mentioned to see which one suits me best. Judging from
> the quick and thorough support from the Python community, I think I
> will stick with a proven framework and/or style, so I can ask a
> question once in a while.

May I suggest Pylons ? It's not yet the more stable and finished option, 
but from what I know of 'classic' ASP and how you explained to usually 
work, I think you might be confortable with it.

> There is probably less sense in trying to pick up a new language while
> at the same time trying to stick to the methods I used in an old
> language.

Hear hear !-)

> But hey, I thought, maybe a thing like this already exists
> exactly like I want it... Ah well.
> 
> Thanks again all, take care!
> 
> Erik
> 
> 
> 



More information about the Python-list mailing list