[mod_python] Writing an Handler for this purpose ??

Nilesh Govindrajan admin at itech7.com
Wed Mar 12 10:48:57 EDT 2008

Aah! Atleast you replied. Thanks a million for replying.

Now, you mean to say something like this -

Set handler mod_python for template files


Write a Handler to parse the template in a variable.


Print the variable using req.write()


Am I right ?

On Wed, Mar 12, 2008 at 7:09 PM, Jorey Bump <list at joreybump.com> wrote:
> Nilesh Govindrajan wrote, at 03/12/2008 12:52 AM:
> > I am soon going to start developing my site in Python and KID after my
>  >  exams are over. I need some help in writing a handler. I am describing
>  >  my question here. Please help me!
>  >
>  > Suppose there is a KID template called home.html
>  >
>  > Now when a visitor requests home.html ; mod_python's handler should
>  >  load the file using the handler without changing the URL.
>  >
>  > The same handler should be able to load any such requested page like
>  >  index2.html
>  >
>  > Any idea about this ?
>  > PS: I need a complete custom system; so I will build it on my own.
>  >  If I had to use some prebuilt CMS then why the hell I would learn
>  >  Programming ?
>  I don't use KID, and I doubt that many other people on this list do,
>  either. However, it looks like it is simple to import and use like any
>  other python module, so you should easily be able to use it with an
>  existing handler like Publisher (just return the serialized string if
>  it's an HTML page), or incorporate it into a custom handler (set
>  req.content_type = "text/html" and req.write(serialized string)).
>  So, your best bet is to get familiar with mod_python, then plan how you
>  want to deliver pages. You need to understand the difference between
>  AddHandler and SetHandler, as it will affect how you construct your
>  URLs, serve files with different extensions, etc.
>  Once you figure out how to serve pages with mod_python, add code to
>  import your templates and return the serialized string. You won't be
>  pointing visitors directly to KID templates (and you'll be able to store
>  the templates outside of your DocumentRoot, if you wish).
>  It also looks like KID can be used in a WSGI application, so you may
>  want to try mod_wsgi, as well, and use the approach you find easiest to
>  understand.

Nilesh G
India Technologies Administrator

More information about the Mod_python mailing list