[ZODB-Dev] transacting multiple databases

hazmat hazmat@objectrealms.net
Tue, 10 Dec 2002 22:13:05 -0800


On Tuesday 10 December 2002 06:51 am, Shane Hathaway wrote:
> hazmat wrote:
> > i thought mounted storage were a zodb feature not a zope one? (at least
> > infrastructure code for them is in the ZODB package). a thought related
> > to allowing mounted storages to participate in local txn. when the
> > mounted storage is opened/traversed (in a getattr sense) it can register
> > a MountedLogicalTxn with the parent connection transaction. the mounted
> > txn can act in effect as a local transaction to the mounted storage. it
> > will proxy txn messages from the parent txn to its registrants.
>
> It's not really a ZODB feature, since it relies on a feature of
> ExtensionClass that ZODB does not use: __of__().  I put Mount.py in the
> ZODB package because I also thought at first that it was a ZODB feature.
> :-)

ok, but as long as zodb works with python2.1 it will ship with extension 
class, so out of the box standalone zodb can use this for mounting zodb with 
python 2.1, and assuming mounted zodb becomes a feature with zope3, it would 
be reasonable to expect a similiar facility for zodb3.5/4, such that mounting 
can be considered a useful feature of zodb without zope?

# gratitous code ;-)
from ZODB.Mount import MountPoint
from ZODB import DB, FileStorage

class FSMount(MountPoint):
	def _createDB(self):
		return DB(FileStorage.FileStorage(self._path))

db = DB(FileStorage('test'))
conn = db.open()
conn.root()['mount1'] = FSMount('test2')

having cross db references would rock as well, but mounting is pretty useful 
as is, imo.

> It will be easy to get everything working together with mounting,
> though.  In addition to the setLocalTransaction() method, we might have
> a setTransaction() method which lets the mounting machinery put both
> connections in the same transaction.  Or perhaps we could make
> connections aware of when they are mounted and pull the transaction from
> their parent automatically.  Hmm, for better encapsulation, the second
> option seems best, since right now we're stuffing an extra attribute in
> the mounted connection anyway.

perfect, thats so much easier than what i was prototyping, a corollary to the 
aftermidnight programming rule should include no jetlagged programming :-),

>
> I think the next step is to decide whether the setLocalTransaction()
> code ought to be merged into mainline ZODB.  I'd be happy to do it with
> Jeremy's approval.  (Jeremy, are you reading?)

+1, its useful and often requested here. 

-kapil