[mod_python] importing from a PSP file

Jorey Bump list at joreybump.com
Thu Jan 6 13:51:26 EST 2005


I do what Lee outlines, only I use the default behaviour with a single 
user per VirtualHost arrangement.

Assuming the DocumentRoot is /var/www/domain/site, I extend the path for 
that VirtualHost with this line in http.conf:

  PythonPath "sys.path + ['/var/www/domain/python']"

Now the user/host has a private package repository that is outside the 
DocumentRoot, which also helps to secure sensitive data (in a somewhat 
limited sense). If you are able to use VirtualHosts, there is no reason 
that prevents you from designating a /home/user/public_html directory as 
the DocumentRoot. Keep in mind that the /home/user/python directory will 
need the same type of world-readable permissions in order to work 
(Therein lies the security limitation: other system users will be able 
to read the files. Nonetheless it does offer advantages in a controlled 
environment).

Lee E. Brown wrote:

> Greetings!
> 
> I don't know if this will help you or not, but mod_python actually uses 
> subinterpreters, each of which have their own namespace separate from 
> the main interpreter.
> 
> The default behavior is to create a subinterpreter for each virtual host 
> on the server.  However, you can use the PythonInterpPerDirectory 
> directive so that each directory accessed gets its own namespace based 
> on the absolute path of the directory being accessed.  Or you can use 
> the PythonInterpPerDirective directive to create a namespace based on 
> the directory where the Python*Handler was found.  You can also use the 
> PythonInterpreter directive to force the namespace to be based on a 
> supplied string.
> 
> If you use one of the above means to give each developer his/her own 
> subinterpreter, you can then initialize a proper sys.path statement for 
> each interpreter allowing access to the needed files without polluting 
> other developer's namespaces or overflowing the main interpreter's 
> sys.path variable.
> 
> Best Regards,
> Lee E. Brown
> 
> ----- Original Message ----- From: "Simon Wittber" <simonwittber at gmail.com>
> Cc: <mod_python at modpython.org>
> Sent: Thursday, January 06, 2005 10:38 AM
> Subject: Re: [mod_python] importing from a PSP file
> 
> 
>> We're all actually sharing the same interpreter, which I've just come
>> to understand!
> 
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list