[mod_python] Current working directory

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Nov 5 00:53:35 EST 2001

mod_python doesn't change the current directory, so it's whatever apache
happens to have as cwd, probably the dir from which it was started.

really old versions used to behave exactly as you say, but this had to be
removed, because changing cwd is not a thread-safe operation.

my recommendation is to avoid chdir() and use full paths


On Fri, 2 Nov 2001, [iso-8859-1] Ragnar KjЬrstad wrote:

> Hi
> How does the current working directory get set when working with
> mod_python?
> The problem is that my handler (and modules imported by the handler) is
> trying to access local files, but it can't find them because the current
> directory is not set "properly".
> I tried adding os.chdir() in my handler, but it seems the cwd is still
> random for modules imported from my handler.
> Maybe someone could shed some light on this?
> I think the best thing would be that the directory of the handler would
> be the cwd both when importing the handler and other modules, but if I
> could only set it manually that would also be ok.
> Thanks.
> --
> Ragnar KjЬrstad
> Zet.no
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list