#
3.2 Quick Overview of how Apache Handles Requests

If you would like delve in deeper into the functionality of mod_python, you need to understand what a handler is.

Apache processes requests in phases. For example, the first phase may be to authenticate the user, the next phase to verify whether that user is allowed to see a particular file, then (next phase) read the file and send it to the client. A typical static file request involves three phases: (1) translate the requested URI to a file location (2) read the file and send it to the client, then (3) log the request. Exactly which phases are processed and how varies greatly and depends on the configuration.

A handler is a function that processes one phase. There may be more than one handler available to process a particular phase, in which case they are called by Apache in sequence. For each of the phases, there is a default Apache handler (most of which by default perform only very basic functions or do nothing), and then there are additional handlers provided by Apache modules, such as mod_python.

Mod_python provides every possible handler to Apache. Mod_python handlers by default do not perform any function, unless specifically told so by a configuration directive. These directives begin with "`Python`" and end with "`Handler`"(e.g. `PythonAuthenHandler`) and associate a phase with a Python function. So the main function of mod_python is to act as a dispatcher between Apache handlers and Python functions written by a developer like you.

The most commonly used handler is `PythonHandler`. It handles the phase of the request during which the actual content is provided. Because it has no name, it is sometimes referred to as as generic handler. The default Apache action for this handler is to read the file and send it to the client. Most applications you will write will override this one handler. To see all the possible handlers, refer to Section 5, Apache Directives.