[Zope] Curious Problem

Passin, Tom tpassin@mitretek.org
Fri, 25 Apr 2003 09:56:47 -0400


[stuffduff]

> I have a python external method which reads from an external database,
> unpickles a class object, and concatenates some of the=20
> object's properties
> into a string which is returned by the external method.  The class
> definition is included in the module.
>=20
> When I run it from the linux prompt in the Extensions=20
> directory it behaves
> exactly as it should. The class is successfully unpickled,=20
> the properties
> are read and the string is returned.
>=20
> However, when I set it up as an external method and call it I get the
> infamous:
>=20

Without knowing how you have defined things, this might not be it, but
the most likely cause of problems like this is the Python path.  When
you run the module from the command prompt, in the Extensions directory,
you are probably using your ordinary Python installation, and the
Extensions directory will be on the Python path because it is the cwd
when you launched Python.

When you run from Zope, you use Zope's Python interpreter, which uses a
different Python path, and Extensions may not be on it.

When I run external methods, I always put all the real code in a package
somewhere else, outside of the Zope directory tree, and add that
location to Zope's Python path, usually using a *.pth file.  The method
in the Extensions directory just imports my package and then calls
something in it, no more.  This has always worked well for me and is
easy to set up.

Cheers,

Tom P