[Zope] How to access ZODB from python code

Gabriel Genellina gagenellina@softlab.com.ar
Wed, 26 Mar 2003 22:27:11 -0300


At 25/3/2003 20:43, you wrote:

>  > I want to get access to some Zope objects stored in ZODB, from 
> *outside* of
>  > any other Zope object (so I dont have anything to call 
> getPhysicalRoot() or
>  > restrictedTraverse() on) but from *inside* python code running in the 
> Zope
>  > process.
>  > This doesnt work:
>  >
>  >          from Zope import Zope
>  >          app = Zope.app()
>  >          app.restrictedTraverse(...)
>  >
>  > The Zope server freezes, I guess there is a deadlock there.
>
>Does this already happens for the first time?
>
>It would be understandable when it happes after some successes
>unless you close the ZODB connection when you are finished:
>
>        Zope.app() opens a ZODB connection which must be closed
>        later. There is a connection pool (of 7 connections, by default).
>        The application blocks when there are no free connections.

Yes, we do close the connection. This is the full fragment:

     app = Zope.app()
     obj = app.restrictedTraverse(path)
     get_transaction().commit()
     app._p_jar.close()
     del app
     return obj

The server freezes inside the restrictedTraverse call (never returns).


Gabriel Genellina
Softlab SRL