[Zodb-checkins] SVN: ZODB/branches/ctheune-blobsupport/src/ZEO/ Add
a ZEO test for a blob-adapted filestorage,
fix bug that prevented storage of empty blobs.
Chris McDonough
chrism at plope.com
Tue Jun 14 01:53:38 EDT 2005
Log message for revision 30788:
Add a ZEO test for a blob-adapted filestorage, fix bug that prevented storage of empty blobs.
Changed:
U ZODB/branches/ctheune-blobsupport/src/ZEO/ClientStorage.py
U ZODB/branches/ctheune-blobsupport/src/ZEO/tests/testZEO.py
-=-
Modified: ZODB/branches/ctheune-blobsupport/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/branches/ctheune-blobsupport/src/ZEO/ClientStorage.py 2005-06-13 22:51:26 UTC (rev 30787)
+++ ZODB/branches/ctheune-blobsupport/src/ZEO/ClientStorage.py 2005-06-14 05:53:37 UTC (rev 30788)
@@ -903,10 +903,13 @@
blobfile = open(blobfilename, "rb")
while True:
chunk = blobfile.read(4096)
+ # even if the blobfile is completely empty, we need to call
+ # storeBlob at least once in order to be able to call
+ # storeBlobEnd successfully.
+ self._server.storeBlob(oid, serial, chunk, version, id(txn))
if not chunk:
self._server.storeBlobEnd(oid, serial, data, version, id(txn))
break
- self._server.storeBlob(oid, serial, chunk, version, id(txn))
os.unlink(blobfilename)
return serials
Modified: ZODB/branches/ctheune-blobsupport/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/branches/ctheune-blobsupport/src/ZEO/tests/testZEO.py 2005-06-13 22:51:26 UTC (rev 30787)
+++ ZODB/branches/ctheune-blobsupport/src/ZEO/tests/testZEO.py 2005-06-14 05:53:37 UTC (rev 30788)
@@ -223,8 +223,41 @@
""" % (self.blobdir, tempfile.mktemp())
def checkStoreBlob(self):
- pass
+ from ZODB.utils import oid_repr, tid_repr
+ from ZODB.Blobs.Blob import Blob
+ from ZODB.Blobs.BlobStorage import BLOB_SUFFIX
+ from ZODB.tests.StorageTestBase import zodb_pickle, ZERO, \
+ handle_serials
+ import transaction
+ somedata = 'a' * 10
+
+ blob = Blob()
+ bd_fh = blob.open('w')
+ bd_fh.write(somedata)
+ bd_fh.close()
+ tfname = bd_fh.name
+ oid = self._storage.new_oid()
+ data = zodb_pickle(blob)
+ self.assert_(os.path.exists(tfname))
+
+ t = transaction.Transaction()
+ try:
+ self._storage.tpc_begin(t)
+ r1 = self._storage.storeBlob(oid, ZERO, data, tfname, '', t)
+ r2 = self._storage.tpc_vote(t)
+ revid = handle_serials(oid, r1, r2)
+ self._storage.tpc_finish(t)
+ except:
+ self._storage.tpc_abort(t)
+ raise
+ self.assert_(not os.path.exists(tfname))
+ filename = os.path.join(self.blobdir, oid_repr(oid),
+ tid_repr(revid) + BLOB_SUFFIX)
+ self.assert_(os.path.exists(filename))
+ self.assertEqual(somedata, open(filename).read())
+
+
test_classes = [FileStorageTests, MappingStorageTests,
BlobAdaptedFileStorageTests]
More information about the Zodb-checkins
mailing list