[Zodb-checkins] SVN: ZODB/branches/3.8/ Fixed bug in TmpStore:
load() would not defer to the backend storage.
Christian Theune
ct at gocept.com
Fri Feb 8 08:54:58 EST 2008
Log message for revision 83666:
Fixed bug in TmpStore: load() would not defer to the backend storage.
Changed:
U ZODB/branches/3.8/NEWS.txt
U ZODB/branches/3.8/src/ZODB/Connection.py
U ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt
U ZODB/branches/3.8/src/ZODB/tests/testblob.py
-=-
Modified: ZODB/branches/3.8/NEWS.txt
===================================================================
--- ZODB/branches/3.8/NEWS.txt 2008-02-08 13:42:35 UTC (rev 83665)
+++ ZODB/branches/3.8/NEWS.txt 2008-02-08 13:54:58 UTC (rev 83666)
@@ -33,7 +33,7 @@
ZEO
---
-- (???) Fixed bug in transaction buffer: a tuple was unpackged incorrectly in
+- (???) Fixed bug in transaction buffer: a tuple was unpacked incorrectly in
`clear`.
- (???) Fixed bug in blob filesystem helper: the `isSecure` check was inversed.
@@ -95,6 +95,9 @@
Blobs
-----
+- (???) Fixed bug in Connection.TmpStore: load() would not defer to the
+ backend storage for loading blobs.
+
- (3.8b5) Fixed bug #130459: Packing was broken by uncommitted blob data.
- (3.8b4) Fixed bug #127182: Blobs were subclassable which was not desired.
Modified: ZODB/branches/3.8/src/ZODB/Connection.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/Connection.py 2008-02-08 13:42:35 UTC (rev 83665)
+++ ZODB/branches/3.8/src/ZODB/Connection.py 2008-02-08 13:54:58 UTC (rev 83666)
@@ -1260,7 +1260,7 @@
self._storage)
filename = self._getCleanFilename(oid, serial)
if not os.path.exists(filename):
- raise POSKeyError("No blob file", oid, serial)
+ return self._storage.loadBlob(oid, serial)
return filename
def _getBlobPath(self, oid):
Modified: ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt
===================================================================
--- ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt 2008-02-08 13:42:35 UTC (rev 83665)
+++ ZODB/branches/3.8/src/ZODB/tests/blob_transaction.txt 2008-02-08 13:54:58 UTC (rev 83666)
@@ -247,7 +247,7 @@
"I'm a happy blob. And I'm singing."
>>> transaction.commit()
-We support optimistic savepoints too:
+We support non-optimistic savepoints too:
>>> root5['blob'].open("a").write(" And I'm dancing.")
>>> root5['blob'].open("r").read()
Modified: ZODB/branches/3.8/src/ZODB/tests/testblob.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/tests/testblob.py 2008-02-08 13:42:35 UTC (rev 83665)
+++ ZODB/branches/3.8/src/ZODB/tests/testblob.py 2008-02-08 13:54:58 UTC (rev 83666)
@@ -443,6 +443,60 @@
"""
+def loadblob_tmpstore():
+ """
+ This is a test for assuring that the TmpStore's loadBlob implementation
+ falls back correctly to loadBlob on the backend.
+
+ First, let's setup a regular database and store a blob:
+
+ >>> import transaction
+ >>> from ZODB.FileStorage.FileStorage import FileStorage
+ >>> from ZODB.blob import BlobStorage
+ >>> from ZODB.DB import DB
+ >>> from ZODB.serialize import referencesf
+ >>> from tempfile import mkdtemp, mktemp
+
+ >>> storagefile = mktemp()
+ >>> base_storage = FileStorage(storagefile)
+ >>> blob_dir = mkdtemp()
+ >>> blob_storage = BlobStorage(blob_dir, base_storage)
+ >>> database = DB(blob_storage)
+ >>> connection = database.open()
+ >>> root = connection.root()
+ >>> from ZODB.blob import Blob
+ >>> root['blob'] = Blob()
+ >>> connection.add(root['blob'])
+ >>> root['blob'].open('w').write('test')
+ >>> import transaction
+ >>> transaction.commit()
+ >>> blob_oid = root['blob']._p_oid
+ >>> tid = blob_storage.lastTransaction()
+
+ Now we open a database with a TmpStore in front:
+
+ >>> database.close()
+
+ >>> from ZODB.Connection import TmpStore
+ >>> tmpstore = TmpStore('', blob_storage)
+
+ We can access the blob correctly:
+
+ >>> tmpstore.loadBlob(blob_oid, tid) # doctest: +ELLIPSIS
+ '.../0x01/0x...blob'
+
+ Clean up:
+
+ >>> database.close()
+ >>> import shutil
+ >>> shutil.rmtree(blob_dir)
+
+ >>> os.unlink(storagefile)
+ >>> os.unlink(storagefile+".index")
+ >>> os.unlink(storagefile+".tmp")
+"""
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ZODBBlobConfigTest))
More information about the Zodb-checkins
mailing list