[ZODB-Dev] Closing ZODB connection

Christian Robottom Reis kiko at async.com.br
Fri Oct 31 07:28:54 EST 2003


On Fri, Oct 31, 2003 at 10:57:04AM +0100, Antonio Beamud Montero wrote:
>    method_A()
>      con = self.db.open()
>      ...<process>
>      con.close()                         method_B()
>      x = self.method_B()    ----------->    con = self.db.open()
>      con = self.db.open()                   ...<process>
>      ...<process>                           con.close()
>      con.close()
> 
> Is the correct approach or is better only open in A and close when exit
> A? i.e. something like:
>    method_A()
>       con = self.db.open()
>       ...<process>                         method_B()
>       x = self.method_B() ---------------      ...<process>
>       ...<process>
>       con.close()  

Both are fine -- you could even pass the connection as an argument to
method_B. The only thing you need to make sure is that you use the
root (and any other objects) that are specific to its respective
connection. One way to debug this is to look at the object's _p_jar
attribute, which is a reference to its [original] connection.

> Thanks for all and sorry if my questions seems stupid... ;-)

Actually, no questions are worthless, but it does make sense to think
things through thoroughly before asking the mailing list, since we all
have those dreaded `real jobs' too.

We'd really benefit from contributed documentation that covered the
common usage patterns of the ZODB.

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331



More information about the ZODB-Dev mailing list