[Zope-dev] API for creating sub-ZODBs

Jim Fulton jim@digicool.com
Wed, 20 Oct 1999 12:50:53 -0400


"Andrew M. Kuchling" wrote:
> 
> Jim Fulton writes:
> >It is.  After your through with the object, you should
> >close the connection.
> 
> Maybe it should return the connection instead, then, so the caller can
> retrieve the root object, do whatever with it, and then close the
> connection.

Take a look at the ZODB.ZApplication module. (And the ZPublisher
package in the ZODB model.)  It illustrates an approach for automagic
connection management.

> >Which job? What part do you want to automate?
> 
> Checking whether the Storage for this ZODB has already been opened,
> and ensuring that everything is neatly cleaned up when you're done.
> 
> >What do you intend to do with the objects you get this way?
> 
> Whatever you like -- call methods on them, mostly, and possibly modify
> them. 

If you modify them, then you need to interact with teh transaction 
machinery.  You have to define transaction boundaries yourself, 
or you need to let Zope do it.  If you let Zope do it, then you need to
keep the connection open until the end of the request, or at least until the
end of the transaction.  There's an (untested) hook for keeping a connection
open until the end of the current transaction. See the documentation for the
database open method.  ZApplication illustrates how to keep a connection open
until the end of a request.

> The two applications I have in mind are, first, the massive
> Open Directory Project tree, and second, persistent session tracking
> that would survive a Zope crash or system reboot (needed when people
> are assembling sequences of process fabrication steps).  In the first
> case, the database is read-only; in the second case, a non-versioning
> storage can be used, because we don't want to track every single edit.

We plan to provide the ability to combine multiple databases in a single
object space.  There are alot of subtle issues with doing this correctly.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.