ZODB.FileStorage -- copy? save as?

Jeremy Hylton jeremy at alum.mit.edu
Wed Feb 6 04:09:42 CET 2002


Mitch Chapman <Mitch.Chapman at bioreason.com> wrote in message news:<3C606CCE.ACA1472D at bioreason.com>...
> I'd like to be able to do something like "save as" with
> ZODB.FileStorage.FileStorage or a derivative thereof.  I'm having a 
> hard time even identifying alternatives, mostly because I don't yet
> understand the FileStorage implementation.

I hope you don't need to understand the implementation in order to use
it.  I'll grant that there's a lot of folklore about how to manage a
FileStorage that isn't documented anywhere.

> F'rinstance I don't know if/when it's safe to copy the associated 
> files ('foo', 'foo.tmp'), whether or not one needs to copy the tmp
> file, what the tmp file does, how one might attach an existing DB 
> to a new FileStorage instance, etc.

It's safe to copy the file "foo" -- assuming you mean what is by
convention called "Data.fs".  Data.fs.tmp is used to store temporary
data while a transaction is committing.  There's also Data.fs.index
which is good to copy, because having an index makes the initial open
of the storage faster.

I'm not sure that "attaching an existing DB to a new FileStorage" is a
sensible  thing to do; i.e. it's not a sensible question, although it
may not be obvious why.  A FileStorage is a log of all the
transactions committed on a DB.  You can't just copy (as in cp) one
file to another, because you don't know anything about the
transactions or objects in the log.

There's a storage level api for copyTransactionsFrom that copies
transactions from one storage to another, but that's still a feature
that should only be used if you know what you are doing.  It's more
likely that you'd want to copy objects at the ZODB level; load an
object graph out of one storage and create copies of all the objects
in a new storage.
 
> Can anyone provide clues?  So far all I have found is the source 
> code itself :) and 
> 	http://www.zope.org/Documentation/Developer/Models/ZODB/

Hope this was helpful.

Jeremy



More information about the Python-list mailing list