[Zope] How to access ZODB from python code

Gabriel Genellina gabrielg_laburando@yahoo.com.ar
Sat, 5 Apr 2003 22:06:17 -0300 (ART)


dieter@handshake.de wrote at Sat, 29 Mar 2003 01:04:17
+0100:

> > 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). 

> I suspect there is some hidden and rarely exposed
locking bug in Zope 
> causing Zope to stop responding to requests due to a
deadlock. 
> I dearly would like to locate and fix it. But, I am
unable to 
> reproduce the situation reliably. 

> Maybe, your setup provides a way for reproduction. 

The good (or bad) news is that the problem is gone.
But I can tell you the following:

- it happened inside restrictedTraverse. I replaced
that call with a quick, dirty and stupid iterative
function using split + getattr, and the code worked
well.

- it was random. Sometimes the same call that worked
fine a few seconds ago would hang the Zope server
then.

- right now, I cannot reproduce the error, even using
the original restrictedTraverse call. 

Anyway, we changed our design and now we are using a
single instance of a Product located at site root, so
there is no need to access Zope from 'outside' the
ZODB.

I cannot tell what has changed in order to make this
code work now. The database (FileStorage) was packed
(and then we got some "Bad reference" errors); there
were some __setstate__ methods not being called
properly; some classes were improperly declared as
descendants of both SimpleItem and Persistent; the
machine running Zope was being used for other purposes
at the same time (like CD recording). Maybe the
problem had to do with some of these odd things, maybe
not, but I can't tell.


Gabriel Genellina
Softlab SRL



------------
¡Navegá y ayudá a un chico!
Por cada usuario que se conecte a Internet 
con Yahoo! Conexión en abril, Yahoo! Argentina 
donará un plato de comida para un niño, a través 
de la asociación "Por los chicos".
http://ar.online.yahoo.com