Graham Dumpleton
grahamd at dscpl.com.au
Sat Feb 4 22:53:28 EST 2006
On 05/02/2006, at 2:24 PM, Dave Britton wrote: > On 2/4/06, Dave Britton <dave at davebritton.com> wrote: >> Sure - >> 1. be sure you have mod_python publisher installed - something like >> this >> should be in httpd.conf: >> <Directory /var/www/dave/python/> >> AddHandler python-program .py >> PythonHandler mod_python.publisher >> PythonDebug On >> </Directory> >> >> 2. Then write a python module that has a function named index() in >> it, and >> put it into the directory specified in the conf file. when you browse >> to > the >> module name (not including the .py extension) publisher will run the >> index >> function as if it were the index.html default file in a regular html >> directory. Note that not including the ".py" extension will only work if you have MultiViews enabled. At the same time though, one has to be careful using MultiViews, especially if you have other resources in the directory which share the same basename as a publisher code file but with a different extension. This is because which file out of those with the same basename but different extensions that Apache decides is the correct one is in part determined by information supplied by the users browser. By default the weightings sent by a client browser tend to favour files with extensions of ".html" or ".txt" over your Python code file with a ".py" extension. Also, by default extensions associated with a code based handler are ignored altogether when there are multiple choices. What this all means is that if you do not use a ".py" extension in the URL and start putting other files in the same directories, you might not always see the result returned that you expected. In case you ever have this problem, you should read: http://www.modpython.org/pipermail/mod_python/2005-August/018828.html http://www.modpython.org/pipermail/mod_python/2005-August/018829.html Graham
|