[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/ Committing opened blobs
is disallowed.
Jim Fulton
jim at zope.com
Thu Jun 7 05:08:34 EDT 2007
Log message for revision 76446:
Committing opened blobs is disallowed.
Changed:
U ZODB/trunk/src/ZODB/Connection.py
U ZODB/trunk/src/ZODB/tests/blob_transaction.txt
-=-
Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py 2007-06-07 09:08:27 UTC (rev 76445)
+++ ZODB/trunk/src/ZODB/Connection.py 2007-06-07 09:08:33 UTC (rev 76446)
@@ -613,6 +613,8 @@
raise Unsupported(
"Storing Blobs in %s is not supported." %
repr(self._storage))
+ if obj.opened():
+ raise ValueError("Can't commit with opened blobs.")
s = self._storage.storeBlob(oid, serial, p,
obj._p_blob_uncommitted,
self._version, transaction)
Modified: ZODB/trunk/src/ZODB/tests/blob_transaction.txt
===================================================================
--- ZODB/trunk/src/ZODB/tests/blob_transaction.txt 2007-06-07 09:08:27 UTC (rev 76445)
+++ ZODB/trunk/src/ZODB/tests/blob_transaction.txt 2007-06-07 09:08:33 UTC (rev 76446)
@@ -127,6 +127,7 @@
>>> bool(blob1a._p_changed)
True
>>> blob1afh3.write('woot!')
+ >>> blob1afh3.close()
We can open more than one blob object during the course of a single
transaction::
@@ -171,14 +172,12 @@
>>> root4 = database.open(transaction_manager=tm2).root()
>>> blob1c3 = root3['blob1']
>>> blob1c4 = root4['blob1']
- >>> blob1c3fh1 = blob1c3.open('a')
- >>> blob1c4fh1 = blob1c4.open('a')
- >>> blob1c3fh1.write('this is from connection 3')
- >>> blob1c4fh1.write('this is from connection 4')
- >>> tm1.get().commit()
+ >>> blob1c3fh1 = blob1c3.open('a').write('this is from connection 3')
+ >>> blob1c4fh1 = blob1c4.open('a').write('this is from connection 4')
+ >>> tm1.commit()
>>> root3['blob1'].open('r').read()
'this is blob 1woot!this is from connection 3'
- >>> tm2.get().commit()
+ >>> tm2.commit()
Traceback (most recent call last):
...
ConflictError: database conflict error (oid 0x01, class ZODB.blob.Blob)
@@ -188,7 +187,7 @@
>>> root3['blob1'].open('r').read()
'this is blob 1woot!this is from connection 3'
- >>> tm2.get().abort()
+ >>> tm2.abort()
>>> root4['blob1'].open('r').read()
'this is blob 1woot!this is from connection 3'
@@ -202,7 +201,27 @@
>>> int(blob_size - underlying_size)
91
+You can't commit a transaction while blob files are open:
+ >>> f = root3['blob1'].open('w')
+ >>> tm1.commit()
+ Traceback (most recent call last):
+ ...
+ ValueError: Can't commit with opened blobs.
+
+ >>> f.close()
+ >>> tm1.abort()
+ >>> f = root3['blob1'].open('w')
+ >>> f.close()
+
+ >>> f = root3['blob1'].open('r')
+ >>> tm1.commit()
+ Traceback (most recent call last):
+ ...
+ ValueError: Can't commit with opened blobs.
+ >>> f.close()
+ >>> tm1.abort()
+
Savepoints and Blobs
--------------------
@@ -226,7 +245,7 @@
>>> savepoint = transaction.savepoint(optimistic=True)
>>> root5['blob'].open("r").read()
"I'm a happy blob. And I'm singing."
- >>> transaction.get().commit()
+ >>> transaction.commit()
We support optimistic savepoints too:
@@ -315,6 +334,6 @@
>>> import shutil
>>> shutil.rmtree(blob_dir)
- >>> tm1.get().abort()
- >>> tm2.get().abort()
+ >>> tm1.abort()
+ >>> tm2.abort()
>>> database.close()
More information about the Zodb-checkins
mailing list