[Zodb-checkins]
SVN: ZODB/branches/ctheune-bushy-directory/src/ZODB/
Change TmpStore to create blob savepoint files in a flat
directory in the
Christian Theune
ct at gocept.com
Thu Jun 26 15:32:58 EDT 2008
Log message for revision 87811:
Change TmpStore to create blob savepoint files in a flat directory in the
temporary directory. Add tests.
Changed:
U ZODB/branches/ctheune-bushy-directory/src/ZODB/Connection.py
U ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/blob_transaction.txt
U ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/testblob.py
-=-
Modified: ZODB/branches/ctheune-bushy-directory/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/ctheune-bushy-directory/src/ZODB/Connection.py 2008-06-26 19:19:21 UTC (rev 87810)
+++ ZODB/branches/ctheune-bushy-directory/src/ZODB/Connection.py 2008-06-26 19:32:58 UTC (rev 87811)
@@ -1228,7 +1228,7 @@
assert version == ''
serial = self.store(oid, serial, data, '', transaction)
- targetpath = self._getBlobPath(oid)
+ targetpath = self._getBlobPath()
if not os.path.exists(targetpath):
os.makedirs(targetpath, 0700)
@@ -1247,14 +1247,12 @@
return self._storage.loadBlob(oid, serial)
return filename
- def _getBlobPath(self, oid):
- return os.path.join(self.temporaryDirectory(),
- utils.oid_repr(oid)
- )
+ def _getBlobPath(self):
+ return os.path.join(self.temporaryDirectory(), 'savepoints')
def _getCleanFilename(self, oid, tid):
- return os.path.join(self._getBlobPath(oid),
- "%s%s" % (utils.tid_repr(tid), SAVEPOINT_SUFFIX,)
+ return os.path.join(self._getBlobPath(),
+ "%s-%s%s" % (utils.oid_repr(oid), utils.tid_repr(tid), SAVEPOINT_SUFFIX,)
)
def temporaryDirectory(self):
Modified: ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/blob_transaction.txt
===================================================================
--- ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/blob_transaction.txt 2008-06-26 19:19:21 UTC (rev 87810)
+++ ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/blob_transaction.txt 2008-06-26 19:32:58 UTC (rev 87811)
@@ -243,22 +243,53 @@
>>> root5['blob'].open("r").read()
"I'm a happy blob. And I'm singing."
>>> savepoint = transaction.savepoint(optimistic=True)
+
>>> root5['blob'].open("r").read()
"I'm a happy blob. And I'm singing."
+
+Savepoints store the blobs in the `savepoints` directory in the temporary
+directory of the blob storage:
+
+ >>> os.listdir(os.path.join(blob_dir, 'tmp', 'savepoints'))
+ ['0x03-0x....spb']
>>> transaction.commit()
+After committing the transaction, the temporary savepoint files are moved to
+the committed location again:
+
+ >>> os.listdir(os.path.join(blob_dir, 'tmp', 'savepoints'))
+ []
+
We support non-optimistic savepoints too:
>>> root5['blob'].open("a").write(" And I'm dancing.")
>>> root5['blob'].open("r").read()
"I'm a happy blob. And I'm singing. And I'm dancing."
>>> savepoint = transaction.savepoint()
+
+Again, the savepoint creates a new file for the blob state in the savepoints
+directory:
+
+ >>> os.listdir(os.path.join(blob_dir, 'tmp', 'savepoints'))
+ ['0x03-0x....spb']
+
>>> root5['blob'].open("w").write(" And the weather is beautiful.")
>>> savepoint.rollback()
+
+XXX Currently, savepoint state of blobs remains after a rollback:
+
+ >>> os.listdir(os.path.join(blob_dir, 'tmp', 'savepoints'))
+ ['0x03-0x....spb']
+
>>> root5['blob'].open("r").read()
"I'm a happy blob. And I'm singing. And I'm dancing."
>>> transaction.abort()
+XXX Currently, savepoint state of blobs remains even after an abort:
+
+ >>> os.listdir(os.path.join(blob_dir, 'tmp', 'savepoints'))
+ ['0x03-0x....spb']
+
Reading Blobs outside of a transaction
--------------------------------------
Modified: ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/testblob.py
===================================================================
--- ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/testblob.py 2008-06-26 19:19:21 UTC (rev 87810)
+++ ZODB/branches/ctheune-bushy-directory/src/ZODB/tests/testblob.py 2008-06-26 19:32:58 UTC (rev 87811)
@@ -503,6 +503,7 @@
"blob_basic.txt", "blob_connection.txt", "blob_transaction.txt",
"blob_packing.txt", "blob_importexport.txt", "blob_consume.txt",
"blob_tempdir.txt",
+ optionflags=doctest.ELLIPSIS,
setUp=ZODB.tests.util.setUp,
tearDown=ZODB.tests.util.tearDown,
))
More information about the Zodb-checkins
mailing list