[ZODB-Dev] Accessing Plone through ZEO back door?

Kirby Urner kirby at 4dsolutions.net
Sun Aug 22 02:23:46 EDT 2004


Kapil Thangavelu wrote:

> fwiw, on 2.7 i setup env vars before invoking scripts (sometimes a 
> front end script)
> export INSTANCE_HOME=/somewhere/
> export SOFTWARE_HOME=/somewhereelse
> export PYTHONPATH=$SOFTWARE_HOME:$PYTHONPATH
>
> #script start
>
> #!/bin/env python2.3
>
> import Zope, os
> Zope.configure( os.path.join( os.environ['INSTANCE_HOME'], 'etc', 
> 'zope.conf') )
> app = Zope.app()
>
> which will load up the conf and setup the products path properly (ie 
> if multiple product directories) and use whatever zodb is configured 
> in zope.conf.
>
OK, this appears to work.

I'm still conceptually confused and want to think about all this correctly.

In the above script, because I've configured zope.conf to connect to a 
Data.fs via zeo,
am I now creating a second zeo client within the Python interpreter? Is 
app much
like a clone of the original zope instance -- it shares the same Data.fs 
(same ZODB),
but is here exposed within Python instead of to a browser through the ZMI?

My original understanding was I could not attach an external Python 
interpreter to an
already-running Zope instance *unless* I made both of these clients of 
zeo (some
Medusa thing was an alternative). I'm thinking Zeo is what enables me to 
plug
multiple clients into the same ZODB (in this case, Zope and an external 
Python
script or shell, running another instance of Zope).

According to this picture, if I try to run the above script, but Zeo is 
not in the
picture, and Zope is already up in a browser, the script should fail, 
because
Python will be blocked from sharing the same ZODB (I haven't tested this).

In order for my second client (my Python instance) to understand what my 
Zope
client is doing in the ZODB, it needs to see the same products. Otherwise,
even though it could access the same ZODB, it wouldn't be able to make much
sense of the contents (e.g. the Plone stuff).

My fantasy is: I do something through the web interface (e.g. add a new 
Document
object to a folder), and right away I'm able to do something through the 
Python
interpreter that lets me see this change in the ZODB. Alternatively, I could
programmatically do something through the Python interpreter that would
affect what a user sees through the web interface (I could even add another
Document).

Is this at all an accurate mental model? Perhaps I suffer from some gross
misconceptions about how the pieces fit together. Expert psychotherapy would
be appreciated.

Kirby




More information about the ZODB-Dev mailing list