[Zope] external method: importing and updating method

Dieter Maurer dieter at handshake.de
Tue Oct 3 14:06:40 EDT 2006


Alan wrote at 2006-10-2 18:48 +0100:
>In my external method I have something like this:
>...
>sys.path.insert(0, CCPNPYTHON)

This is not a good idea!

The source of an "External Method" can be read arbitrarily often --
and each time, you extend "sys.path"...

The "imp" module allows you to import modules without the need
to modify "path".

> ...
>the problem I am facing now it that if I update my memops stuff (which
>is found in CCPNPYTHON path) it seems not to be being updated in Zope,
>because Zope is still using the old version. (If I run outside Zope,
>the code works).

That's typical Python behaviour:

  Python does not recognize at runtime when a module source has
  changed.

  It provides however a builtin "reload" which you can use
  to explicitely reload a module.

  Be warned the "reload" is dangerous. Funny effects can happen.


As someone else suggested, restarting Zope is the safest way
(although not the fasted one).



-- 
Dieter


More information about the Zope mailing list