Graham Dumpleton
grahamd at dscpl.com.au
Thu Jan 6 21:51:36 EST 2005
On Jan 07 08:52, Simon Wittber <simonwittber at gmail.com> wrote: > > Subject: Re: [mod_python] importing from a PSP file > > > > 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. > > Brilliant! Just what I need. > > > In short, requests against the directory and a file in the directory map > > to different interpreters when they should be the same. This makes it > > hard to have a default index page served up when directory is accessed. > > Fortunately we do not use index.psp files, so it seems this bug won't effect us. > > To summarise: > > The final 3 lines I added after line 207 in psp.py are: > > cwd = os.path.split(self.filename)[0] > if cwd not in sys.path: > sys.path.append(cwd) > > This allows (along with the PythonInterpPerDirectory driective) > multiple developers, on the same machine, to import different packages > (which reside in the same folder as the .psp file) of the same name > into .psp pages which are served from their public_html folders. There isn't a need to be changing psp.py at all and changing it isn't a good idea as others have said. For the path bit, use PythonPath directive in the users htaccess file instead. Out of the options mentioned as to separate interpreters, use PythonInterpPerDirective instead of the PythonInterpPerDirectory option. Thus, a users .htaccess file in their public_html directory would read something like: AddHandler mod_python .psp PythonInterpPerDirective On PythonHandler mod_python.psp PythonPath "sys.path+'/home/simon/public_html/package'" Or in httpd.conf, as: <Directory /home/simon/public_html> AddHandler mod_python .psp PythonInterpPerDirective On PythonHandler mod_python.psp PythonPath "sys.path+'/home/simon/public_html/package'" </Directory> In someone elses directory, just change the PythonPath setting as is appropriate for their version of the above. What this would then give you is a separate interpreter for stuff rooted at the top of each persons public_html directory. Further, the Python path would include the "package" subdirectory of the public_html directory. The reason for not using PythonInterpPerDirectory, besides the bug, is that if subdirectories were created, under public_html which have .psp files, each of those directories would have a separate interpreter as well. Using PythonInterpPerDirective means the whole directory hierarchy under public_html would share the same one for that one user. -- Graham Dumpleton (grahamd at dscpl.com.au)
|