|
Jorey Bump
list at joreybump.com
Thu Oct 12 16:29:44 EDT 2006
Sells, Fred wrote:
> I tried that and got a "module not found", could you send me a copy of your
> <Directory... from the .conf file. Perhaps I just had a brain fart. I like
> the approach you describe; that's what we did with cgi before changing to
> mod_python.
# add mod_python.publisher capability to specified directory
# doesn't need .py extension in URL
# if module contains index function, it can be left off URL
# directory cannot serve other kinds of files
<Directory /var/www/vhosts/www.example.com/support>
AllowOverride All
SetHandler python-program
PythonHandler mod_python.publisher
PythonDebug On
</Directory>
Assuming test.py contains this:
def hello():
return 'hello'
You would reach it at:
http://www.example.com/support/test/hello
I also usually alias the directory so I can keep it outside the
DocumentRoot:
Alias /support /var/www/vhosts/www.example.com/support
And to facilitate creating frontends, I prepend PythonPath with a
directory exclusive to the VirtualHost:
PythonPath "['/var/www/vhosts/www.example.com/python'] + sys.path"
Then my published modules are minimal frontends to libraries I create
there. There are pros and cons to this approach. YMMV.
|