[Zope] importing an existing python module into Zope python
Sean
whysean at softhome.net
Thu Jan 29 09:42:31 EST 2004
Rachel,
Are you a cypherpunk type? Your name sounds familiar.
To answer your question:
option iii.) is not such a big deal as to earn the term "rewrite"
A "Zope Product" is just a python module in the Zope Products directory with
some code in its "__init__.py" file that tells Zope how to add your objects
from the management interface. You can define a single new Zope object that
imports your existing code (as long as it is in your python path) and
inherits from your existing class(es), or calls your existing functions.
This wrapper class shouldn't require much code at all.
Additionally, when you run zope in Development mode ("-D" from the command
line), and I believe that ./start does this by default, you can set any
product to auto-refresh in the management interface: Control Panel ->
Products -> YourProduct -> <Refresh Tab> Click auto refresh and Update.
Also the product directory may need an empty (size=0) file called
"refresh.txt" for this to work. At least is does in the old version of Zope
I am running.
Be well.
--Sean Hastings
>
> Message: 21
> Date: Wed, 28 Jan 2004 16:38:56 +0000
> From: Rachel Willmer <rachel_lists at willmer.org>
> Subject: [Zope] importing an existing python module into Zope python
> script?
> To: zope at zope.org
> Message-ID: <4017E5A0.9020603 at willmer.org>
> Content-Type: text/plain; charset=us-ascii; format=flowed
>
> 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?
>
> There must be an easier answer that has eluded me to date....
>
> Any answers appreciated...
>
> Rachel
More information about the Zope
mailing list