Graham Dumpleton
grahamd at dscpl.com.au
Fri Jan 27 16:10:30 EST 2006
On 28/01/2006, at 8:01 AM, Sean Jamieson wrote: > Thanks for the quick response Deron. > > Disreguarding the apache issue, what would be the problem with the > working directory being set for publisher scripts? personally I'd > expect to be able to refernce files relative to the script's > directory. > I understand that for generaic handlers this wouldn't quite make > sense; but for publisher and PSP (I don't know if its an issue for > PSP, as I don't use it), it makes sense to me. > > Any clarifiction would be appreciated. You can't change the working directory full stop, even with publisher. In a multithread MPM (default on Win32, optional on UNIX), distinct requests arriving at the same time are handled in different threads. If each thread needed to change the working directory they would interfere with each other and could change the working directory when the other thread is expecting it to be some other value. The only way around this is to acquire a thread lock for the whole time of handling a request, which means that all requests are serialised, which is going to slow your web server done in terms of how many requests it can handle. BTW, no major web framework (Python or otherwise) that I know of changes the current working directory to specific values just for the period of a single request. I know that CGI does and thus mod_python cgihandler does, but it uses the lock above as described, which has the problems as described. The CGI case shouldn't be used as a guide of what is good though. Graham > Deron Meranda wrote: > >> There are two problems with having the working directory set like you >> want >> >> 1. URLs don't have to map to actual directories (and many mod_python >> users depend on this) >> >> 2. The working directory is a process attribute. Changing it would >> cause all kinds of problems in a multithreaded environment (depending >> on your Apache MPM) >> >> Generally, you should either set your PythonPath, or expect to deal >> with absolute pathnames or other such games. >> >> You may also want to look at the mod_python import_module() function, >> which lets you specify a path. Also the request member req.filename >> may be useful to you was well. >> -- >> Deron Meranda >> > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python
|