[Zope] Calling a File from an External Method

Passin, Tom tpassin@mitretek.org
Mon, 13 Jan 2003 16:02:47 -0500


[ Dieter Maurer]

> Apparently, you are using Python's "open" function (or=20
> friend). It resolves relative filenames with respect to the=20
> "currend working directory". The "current working directory"=20
> must not change during Zope execution. Especially, it can not=20
> be dependent on the location of an "External Method" or DTML object.
>=20
> I am not sure, what Zope's current working directory is.
>=20
>   I expect it is the directory where Zope has been started.
>=20
>   But, there are rumors that this may have been changed
>   and the current working directory is now "CLIENT_HOME"
>   (per default the "var" subfolder).
>=20
> Either use absolute path names to your files or find out what=20
> the current working directory is (Python has an function for=20
> thin in the "os" module) and use relative filenames with=20
> respect to this directory.

Another solution is to put the external method in a package or module,
and have the package or module find its own directory, which is wasy to
do.  Then make all your paths relative to the package/module directory.

This way, the code always works no matter where you relocate it to, and
you never have to remember absolute paths nor depend on the current
location (which some other code might decide to change on you).

Cheers,

Tom P