[Zope] importing an existing python module into Zope python script?

Paul Winkler pw_lists at slinkp.com
Wed Jan 28 12:12:41 EST 2004


On Wed, Jan 28, 2004 at 04:38:56PM +0000, Rachel Willmer wrote:
> This *must* be a FAQ, but I haven't found the answer anywhere despite 
> all day looking...
> 
> I've got an existing python module with a large amount of code in it 
> which I want to use both inside Zope and outside in existing python 
> programs. The module is still under development so will change frequently.
> 
> Two burning questions:
> 
> a) How do I get access to the module within Zope ?
> 
> b) What do I then need to do to keep the versions in sync?
> 
> As far as I can see, I have at least 3 alternatives to question (a).
> 
> i) Copy it all into Zope, each function as a separate Zope python script 
> (Ugh! and this then makes keeping it in sync outside Zope pretty darned 
> difficult...)
> 
> ii) Keep the module as-is and add an External Method in Zope for each 
> function that will be called from a Zope script. Pretty awful but 
> do-able. But then I think I need to do something else in the Zope 
> Management Interface each time I change the module? Is that right?
> 
> iii) Rewrite it all as a Zope Product?

iv) write a Zope Product that wraps your class(es).
That's probably the most common approach.
If the API is good, you won't have to modify the wrapper 
much, if ever.

If your existing module changes on disk, you will have to refresh 
the product or restart zope before it will see the changes.

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's FLUORO-SOLID WHORE!
(random hero from isometric.spaceninja.com)



More information about the Zope mailing list