[Zope-dev] How to read ZODB with Python script?

Shane Hathaway shane@digicool.com
Thu, 15 Feb 2001 12:08:29 -0500


Steve Alexander wrote:
> 
> Petr Knapek wrote:
> 
>  >
>  > I would like to know how to connect to running Zope ZODB from
>  > a  python script.  I would like to have possibility to read
>  > only  objects from ZODB?  Is there any possibility how to do
>  > it when Zope application server is running and not to corrupt
>  > the ZODB?
> 
> This was asked on the zope-dev@zope.org list only a few weeks ago. You
> can look up the discussion in the list archives.
> 
> The best solution is for you to use ZEO, and write your python
> object-reader as a ZEO Storage Client.
> 
> I believe this is easier than it might sound, although I haven't tried
> it myself.
> 
> (did I get the terminology right?)

Yep, and it's actually *really* easy.  Once you have your Zope running
on ZEO, you just write a script with these two lines:

import Zope
app = Zope.app()

Now "app" refers to the root folder.  Read and change objects to your
heart's content.  (Seriously!)  Then just call:

get_transaction().commit()

It can't get any easier than that.  You can even do all this using the
interactive prompt.

Shane