Thanks to all who replied.  The pointer to the correct documentation will be
most helpful.

I just awoke (at 2 a.m.) with the way forward.  In true prototype fashion,
Leo's new zodb-read and zodb-write commands will simply disallow multiple
connections.  So at most one 'zodb outline' can be open at any time and a
zodb/Leo outline will use a single, long-lasting connection.

This scheme is dead simple (and can easily be tested!) and it will give
Leo's users at least 90% of what they want, namely the ability to store and
retrieve any particular Leo outline in a zodb.  Indeed, this prototype is
likely to be all that is ever needed.

Another approach would be to have in-memory copies of the objects in  the
zodb (they could even be the same class, just without a database
connection).  Saving the file pushes the copy's data to the ZODB and
commits a transaction.

The more I consider this scheme, the more dubious it looks.  I went to bed
with these objections:

1.  Making copies of objects is expensive in both time and space.  Leo
outlines can be big, and all these copies would unduly stress Python's
garbage collector.

2.  Making copies of objects risks losing the identity of the original zodb
(persistent) objects.  True, the copied objects might contain a reference to
the zodb objects, but keeping such references assumes the zodb objects
'stick around' after a connection is closed.  There is enough magic in the
zodb that this assumption is dubious.  And I don't want to change Leo's
fundamental data objects to include such references.

3. Most importantly, the fundamental operation implied by this scheme is not
a tree *copy*, but a tree *compare*.  Unless Leo simply does a mass copy of
all copied (Leo) nodes to the zodb, Leo, not the zodb, will be responsible
for knowing which *zodb* objects should be changed!  Far from being a
straightforward solution, this is an 'heroic' solution.  And it's so ugly:
it duplicates all the work that should be done by zodb in updating objects.

In short, copying nodes is way too much work for way too little gain.  In
the unlikely event that Leo's users demand that more zodb/Leo outline be
open at once, I would explore how to make transactions 'local' to a
particular outline.  For now, a very simple prototype should more than
suffice.

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  [EMAIL PROTECTED]
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------

_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to