[mod_python] VirtualHost

Graham Dumpleton grahamd at dscpl.com.au
Fri Dec 29 19:34:34 EST 2006


On 29/12/2006, at 6:22 PM, <rickzolun1 at charter.net> wrote:

> The following is working:
>
> <VirtualHost *:80>
>     ServerName srv01.local
> 	DocumentRoot "C:/Company/apps"
>     <Location "/">
>         AllowOverride None
>         Order allow,deny
>         Allow from all
>
>         PythonPath "['C:/Company/apps/ClientX/ProductY','C:/Company/ 
> scripts'] + sys.path"
>         SetHandler mod_python
>         PythonHandler mpcp
> 		PythonDebug On
> 		PythonOption cherrysetup project_start::mp_setup
>     </Location>
> </VirtualHost>
>
> Questions
>
> 1. I would prefer to have relative path
> <Location "/ClientX/ProductY">
>  .........
> <Location>
> but this is not working. I get "Forbidden  You don't have  
> permission to access / on this server." message when I do this.

You should be able to use Location like that, but you may have  
provide extra
configuration information for CherryPy so it knows that is being used  
for a
directory which isn't the root of the web site.

> How can I use relative paths?

What exactly do you mean by that? The term relative path means something
specific and your use of the term doesn't completely make sense in  
this context.

I think perhaps you mean a URL path as distinct from file system path?

> 2. Are relative paths allowed in PythonPath?

No. All paths in PythonPath must be absolute.

> Different context...
>
> 3. It appears that environment variables cannot be used in the  
> Python code with mod_python (os.environ.get). Is there an alternate  
> recommended approach?

If you are using CherryPy it will depend on whether they propagate  
through in
some way mod_python configuration which can be specified using the
PythonOption directive. Normally in mod_python you get access to this  
through
the request object using req.get_options(), but CherryPy probably  
hides the
mod_python request object with its own wrappers and so you can't get  
to it.

Similarly using SetEnv directory may also be no good if CherryPy  
doesn't allow
you access to req.subprocess_env table in mod_python request object.

You may be better off asking on some CherryPy forum as it relates  
more to
that product than mod_python.

Graham


More information about the Mod_python mailing list