RCS diff for mod_python FAQ entry
===================================================================
RCS file: RCS/faq03.004.htp,v
retrieving revision 1.247
retrieving revision 1.248
diff -r1.247 -r1.248
2,4c2,4
< Last-Changed-Date: Mon Mar 3 11:51:50 2008
< Last-Changed-Author: The Phantom Returns
< Last-Changed-Email: removal@everywere.com
---
> Last-Changed-Date: Mon Mar 3 15:33:55 2008
> Last-Changed-Author: jonn3
> Last-Changed-Email: email@gmail.com
6c6
< Last-Changed-Remote-Address: 68.253.111.184
---
> Last-Changed-Remote-Address: 85.255.120.90
8,66c8,44
< The standard config
<
< <Directory /mywebdir>
< AddHandler python-program .py
< PythonHandler myscript
< PythonDebug On
< </Directory>
<
< forces all .py URLs in that directory to use the "myscript.py" handler, even for random, non-existent filenames. This implies one directory
< per application.
<
< If you want to have multiple applications in a directory, or want to force the URL to refer to a real, existing .py file, then you might try something like this:
<
< <Directory /mywebdir>
< AddHandler python-program .py
< PythonDebug On
< <Files "myscript.py">
< PythonHandler myscript
< </Files>
< </Directory>
<
< and so on, perhaps with multiple <Files> sections, one per application. But this doesn't work, because putting the Handler declaration inside a <Files> section means that the sys.path is no longer updated to include the directory containing the scripts, so the URL fails with a python import error.
<
< The trick is to explicitly add the directory to the head of sys.path (putting it at the end of the path gives odd results when the URL name clashes with a module elsewhere in the path):
<
< <Directory /mywebdir>
< AddHandler python-program .py
< PythonDebug On
< PythonPath "['/mywebdir'] + sys.path"
< PythonHandler default
< </Directory>
<
< Then (either in /mywebdir/.htaccess or inside the httpd.conf <Directory> section) add a <Files> section for each script:
<
< <Files "prog1.py">
< PythonHandler prog1
< </Files>
< <Files "prog2.py">
< PythonHandler prog2
< </Files>
<
< This will cause URLs continaing prog1.py or prog2.py to be handled by the respective scripts. All other .py URLs will be handled by the default.py module specified in the PythonHandler directive in the <Directory> section. If you omit this directive, then any URLs not explicitly matched in a <Files> section will either return the text of the .py file (if it exists) or return a "Not Found" error. So be careful to keep the .htaccess file up to date else you will leak possibly sensitive information in the program code.
<
< Note: this won't work for a single directory of .py files which are a mixture of CGI and mod_python scripts!
<
< NB: The above was written for mod_python 2.7.1; for mod_python 3 this won't work, due to what seems to be an undocumented change in the way PythonPath works. For mod_python 3, you need to put the PythonPath directive inside a Files directive like so:
<
< <Directory /mywebdir>
< AddHandler python-program .py
< PythonDebug On
< <Files *.py>
< PythonPath "['/mywebdir'] + sys.path"
< </Files>
< PythonHandler default
< </Directory>
<
< ------
<
< Alternatively, use one of the extensions available to mod_python which can dispatch to multiple resources in one directory. The one which gives the best match to what is trying to be achieved here is Vampire (http://www.dscpl.com.au/projects/vampire). Another worth checking out is mpservlets (http://home.comcast.net/~d.popowich/mpservlets), although it models handlers as servlet like objects rather than a basic content handler.
---
> money need i'm , <a href="http://youralonegirls.com/xxx-teen-hardcore.html">xxx teen hardcore
> </a>[url="http://youralonegirls.com/xxx-teen-hardcore.html"]xxx teen hardcore
> [/url]http://youralonegirls.com/xxx-teen-hardcore.html xxx teen hardcore
> qrtlc, <a href="http://youralonegirls.com/pedo-lolitas/12yo-little-lolitas.html">12yo little lolitas
> </a>[url="http://youralonegirls.com/pedo-lolitas/12yo-little-lolitas.html"]12yo little lolitas
> [/url]http://youralonegirls.com/pedo-lolitas/12yo-little-lolitas.html 12yo little lolitas
> 3582, <a href="http://youralonegirls.com/bd-company-pics/bd-company-pics-trinidad-and-tobago.html">bd-company pics Trinidad and Tobago
> </a>[url="http://youralonegirls.com/bd-company-pics/bd-company-pics-trinidad-and-tobago.html"]bd-company pics Trinidad and Tobago
> [/url]http://youralonegirls.com/bd-company-pics/bd-company-pics-trinidad-and-tobago.html bd-company pics Trinidad and Tobago
> 71395, <a href="http://youralonegirls.com/teen-girl-lesbians.html">teen girl lesbians
> </a>[url="http://youralonegirls.com/teen-girl-lesbians.html"]teen girl lesbians
> [/url]http://youralonegirls.com/teen-girl-lesbians.html teen girl lesbians
> imtwsh, <a href="http://youralonegirls.com/nude-preteen-pic/8-9yo-nude-preteen-pic.html">8-9yo nude preteen pic
> </a>[url="http://youralonegirls.com/nude-preteen-pic/8-9yo-nude-preteen-pic.html"]8-9yo nude preteen pic
> [/url]http://youralonegirls.com/nude-preteen-pic/8-9yo-nude-preteen-pic.html 8-9yo nude preteen pic
> %))), <a href="http://youralonegirls.com/pedo-lolitas/little-lolitas.html">little lolitas
> </a>[url="http://youralonegirls.com/pedo-lolitas/little-lolitas.html"]little lolitas
> [/url]http://youralonegirls.com/pedo-lolitas/little-lolitas.html little lolitas
> 596, <a href="http://youralonegirls.com/teen-lesbians-masturbating.html">teen lesbians masturbating
> </a>[url="http://youralonegirls.com/teen-lesbians-masturbating.html"]teen lesbians masturbating
> [/url]http://youralonegirls.com/teen-lesbians-masturbating.html teen lesbians masturbating
> 8026, <a href="http://youralonegirls.com/lolita-fuck/lolita-fuck-gabon.html">lolita fuck Gabon
> </a>[url="http://youralonegirls.com/lolita-fuck/lolita-fuck-gabon.html"]lolita fuck Gabon
> [/url]http://youralonegirls.com/lolita-fuck/lolita-fuck-gabon.html lolita fuck Gabon
> =D, <a href="http://youralonegirls.com/pedo-lolitas/9-little-lolitas.html">9 little lolitas
> </a>[url="http://youralonegirls.com/pedo-lolitas/9-little-lolitas.html"]9 little lolitas
> [/url]http://youralonegirls.com/pedo-lolitas/9-little-lolitas.html 9 little lolitas
> 8[, <a href="http://youralonegirls.com/pedo-lolitas/9-10-pedo-lolitas.html">9-10 pedo lolitas
> </a>[url="http://youralonegirls.com/pedo-lolitas/9-10-pedo-lolitas.html"]9-10 pedo lolitas
> [/url]http://youralonegirls.com/pedo-lolitas/9-10-pedo-lolitas.html 9-10 pedo lolitas
> 76855, <a href="http://youralonegirls.com/bd-company-pics/bd-company-pics-saint-kitts-and-nevis.html">bd-company pics Saint Kitts and Nevis
> </a>[url="http://youralonegirls.com/bd-company-pics/bd-company-pics-saint-kitts-and-nevis.html"]bd-company pics Saint Kitts and Nevis
> [/url]http://youralonegirls.com/bd-company-pics/bd-company-pics-saint-kitts-and-nevis.html bd-company pics Saint Kitts and Nevis
> 38479, <a href="http://youralonegirls.com/bd-company-pics/bd-company-pics-uganda.html">bd-company pics Uganda
> </a>[url="http://youralonegirls.com/bd-company-pics/bd-company-pics-uganda.html"]bd-company pics Uganda
> [/url]http://youralonegirls.com/bd-company-pics/bd-company-pics-uganda.html bd-company pics Uganda
> 7375,
mod_python home /
mod_python FAQ Wizard 1.0.3 /
Feedback to grisha