You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Jim Gallacher <jp...@jgassociates.ca> on 2006/12/02 19:14:52 UTC
Re: [Mod_python Wiki] Update of "MostMinimalRequestHandler" by JoreyBump
Apache Wiki wrote:
> Dear Wiki user,
>
> You have subscribed to a wiki page or wiki category on "Mod_python Wiki" for change notification.
>
> 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
> + }}}
FYI, you can get python syntax highlighting by starting your code block
with {{{#!python
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.
Jim
Re: [Mod_python Wiki] Update of "MostMinimalRequestHandler" by JoreyBump
Posted by Jim Gallacher <jp...@jgassociates.ca>.
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
Re: [Mod_python Wiki] Update of "MostMinimalRequestHandler" by JoreyBump
Posted by Jorey Bump <li...@joreybump.com>.
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. :)
> FYI, you can get python syntax highlighting by starting your code block
> with {{{#!python
Thanks for the tip.
> 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).
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.