quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Gallacher <...@jgassociates.ca>
Subject Re: [Mod_python Wiki] Update of "MostMinimalRequestHandler" by JoreyBump
Date Sat, 02 Dec 2006 20:12:56 GMT
Jorey Bump wrote:
> Hi, Jim:
> 
> Jim Gallacher wrote:
>>> The following page has been changed by JoreyBump:
>>> http://wiki.apache.org/mod_python/MostMinimalRequestHandler
>>>
>>> ------------------------------------------------------------------------------

>>>
>>>     Let's begin at the beginning. Here is the most minimal request 
>>> handler possible:
>>>   + {{{
>>>     def handler(req):
>>>         return 0
>>> + }}}
> 
> This is my first use of moinmoin, so I saved more frequently than 
> necessary. I've already improved the page and discovered the preview 
> button. :)

I'm a moinmoin newbie myself. Everything I know about it I learned while 
sipping my morning coffee today. :)

>> FYI, you can get python syntax highlighting by starting your code 
>> block with {{{#!python
> 
> Thanks for the tip.

The syntax highlighting with line number will be nice to have when 
explaining code. I was certainly pleased when I stumbled upon it.

>> Also I would avoid using "return 0". I know you want it to be the most 
>> minimal handler possible, but I think it's better to encourage good 
>> coding habits by using "return apache.OK". It will then be more 
>> logical when users move on to more sophisticated handlers, perhaps in 
>> other phases, where the handler may be returning something other than 0.
> 
> I've explained this in the final draft, and moved on to using apache.OK 
> in the next example. This handler is obviously meant to do nothing, but 
> to the uninitiated, the mod_python voodoo is quite thick. We take it for 
> granted, but I think a novice will appreciate that the return code 
> should be an integer (after all, that's what the debugger complains 
> about if there's a related error).
> 
> One of the things we're up against is that I suspect a good chunk of our 
> audience has no Python experience whatsoever, and they come to 
> mod_python investigating alternatives to other web application 
> development languages, like PHP. We can't assume they'll have many 
> Python (or Apache) skills at all, so we should take the opportunity to 
> ease them into basic concepts upfront (without dumbing it down, of course).

I suspect that many new mod_python users are familiar with python but 
have been forced to use PHP in the past and are desperate to return to 
the sanity of python. :)

The lack of Apache knowledge is the bigger challenge. People don't 
immediately grok the power of mod_python because the concept of 
different processing phases in apache is completely foreign. If we can 
crack that nut I think mod_python could become much more popular.

> You could argue that it would be silly for a novice to start out by 
> writing a custom handler, but the mailing list indicates that it happens 
> all of the time.

Even if someone has some mod_python experience writing a custom handler 
for the first time can be a bit daunting, so I like your idea of 
starting with something very simple and building from there.

Jim


Mime
View raw message