handler(req)
This handler uses instances of subclasses of Servlet
to handle HTTP GET and POST requests. These instances are referred to
as servlets in this documentation.
Overview of how it works:
-
A developer creates a class that subclasses
Servlet or, more probably, HTMLPage , which already subclasses Servlet and has many features for
generating HTML.
-
Let's say we have a class named Foo that subclasses
HTMLPage . This class must be saved in
a file called Foo.mps. (mps stands for Mod Python Servlet).
Generally, for any servlet named SERVLET, it must be a subclass
of Servlet and saved in a file named
SERVLET.mps.
-
Apache needs to be configured to call this handler for Foo.mps.
Assuming /var/www/html is your DocumentRoot and also assuming
Foo.mps is saved in directory /var/www/html/mps_test then Apache
needs the following configuration:
<Directory /var/www/html/mps_test>
SetHandler mod_python
PythonHandler mod_python.servlet
PythonDebug on
</Directory>
-
When the server receives a request for /mps_test/Foo it
will look for a file named Foo.mps in /var/www/html/mps_test,
compile the file, look for a class named Foo, insure it is a
subclass of
Servlet , create an instance of this
class, let's call it servlet , and then call, in
order:
-
servlet.auth ()
-
servlet.prep ()
-
servlet.respond ()
-
servlet.wrapup ()
See the documentation for the above methods of Servlet for details about each stage
of processing the request.
-
Instances of a class are cached, so if a request for
/mps_test/Foo comes in another request, the instance will be
found in the cache and reused.
See the documentation for Servlet and HTMLPage for further details about
servlet processing and helpful features.
If installed, see the tutorial for a live demonstration of
servlets. See the README file that came with this distribution for
tutorial installation instructions.
-
|