[Zope] problem with adding an external method

Dieter Maurer dieter at handshake.de
Wed Aug 24 14:16:27 EDT 2005


Scott Mann wrote at 2005-8-23 10:00 -0700:
> ...
>I am attempting to add the external python module "nb_fetch" Doing so returns the error message:
>
>    "Module /data/zope/testbed/initialzope/Extensions/nb_fetch.py, line 3, in ?
>
>             ImportError: No module named nb_parse"
>
>where nb_parse is imported by nb_fetch.

Note that Zope does not use Python's normal import mechanism
to load the source file for "External Method"s.
One impact: you cannot use relative imports:

   Even if "nb_fetch.py" and "nb_parse.py" lie side by side in
   the same folder, "nb_fetch.py" cannot simple do
   an "import nb_parse" to access the other module.

> ...
>I have also made a number of attempts at adding directories to the PYTHONPATH, but no success.

If "nb_parse.py" is in a folder listed in PYTHONPATH,
the "import nb_parse" should succeed.

> ...
>Also, I restart zope every time I make a change.

Change what?

If you change the source file of an "External Method" *AND*
you run your Zope in "development mode", then changes are
recognized automatically.

Chances in other Python modules (such as your "nb_parse" above)
require a Zope restart.

-- 
Dieter


More information about the Zope mailing list