Mod_python is an Apache only module. Mod_python version 3.x requires Apache 2.x and Python 2.2.1. For Apache 1.3 only mod_python 2.x can be used. This tutorial requires mod_python 3.1+

Much faster than CGI

For every requested CGI page the Python interpreter must be launched. With mod_python Apache starts one main interpreter for the main server and one subinterpreter for each virtual host and these interpreters will be reused for all requests. They will never finish until the server is shut down.

Mod_python handlers

Apache processes requests in phases. A handler is a function that processes a particular phase of a request. Handlers are provided by Apache and by its modules, like mod_python.

A number of handlers are available in mod_python. Most of them are low level replacements for Apache handlers but two, Publisher and PSP, are high level and will be covered here.

The PSP handler processes text documents with Python code embedded between <% and %> tags and transform it in pure Python code, much like PHP and ASP. If you are used to these and don't wan't to learn a new web programming paradigm then PSP is your choice.

The Publisher handler allows access to functions and variables within a module via URLs. It avoids the spagetthi coding style thus giving the code a much more application like appearance.

If your *nix distribution offers a package to install mod_python use it. If it does not or you're using Windows download from