[Zope] "import" within external method file doesn't work
Rik Hoekstra
hoekstra@fsw.leidenuniv.nl
Tue, 28 Dec 1999 12:56:38 +0100
From: christian@newopenness.de
Date sent: Tue, 28 Dec 1999 01:04:53 +0100
To: zope@zope.org
Subject: [Zope] "import" within external method file doesn't work
> Hello all,
>
> I've tried to write a simple external method as described a thousand
> times in the excellent documentation.
> Within the file "A", I'd like to import another file "B" within the same
> directory. But when I try to add a function from "A" as an external
> method somewhere in the tree and try to view the DTML document from
> which the method is called, Zope tells me that it can't find the module
> I tried to import in "A". Is this a bug or I'm too much newbie?
too much newbie ;-)
The point is that the python modules in the Extensions directory are
not really modules _and_ they cannot import from the Extensions
directory itself. You should put your module_to_be_imported somewhere
in a directory in the pythonpath.
<zopehome>/lib/python/Shared/<yourstuff> is a good place. Don't
forget to add a (presumable empty) __init__.py module in the
<yourstuff> directory. The module may then be imported by the python
statement
import Shared.<yourstuff>.yourmodule
or
from Shared.yourstuff import yourmodule.
See the standard python documentation on http://www.python.org for
more information on all this.
Rik