[Zodb-checkins] SVN: ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt Add a test to show that our cleanup code (currently in "_abort") doesn't get called. The complexity of the proxied storage, the connection as a datamanager, and the transaction indirections make it unclear exactly how to hook a transaction abort for cleanup purposes.

Chris McDonough chrism at plope.com
Sat Sep 24 14:25:06 EDT 2005


Log message for revision 38600:
  Add a test to show that our cleanup code (currently in "_abort") doesn't get called.  The complexity of the proxied storage, the connection as a datamanager, and the transaction indirections make it unclear exactly how to hook a transaction abort for cleanup purposes.
  
  

Changed:
  U   ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt

-=-
Modified: ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt
===================================================================
--- ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt	2005-09-24 17:35:59 UTC (rev 38599)
+++ ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt	2005-09-24 18:25:06 UTC (rev 38600)
@@ -26,17 +26,31 @@
     >>> blob_dir = mkdtemp()
     >>> blob_storage = BlobStorage(blob_dir, base_storage)
     >>> database = DB(blob_storage)
+    >>> connection1 = database.open()
+    >>> root1 = connection1.root()
+    >>> from ZODB.Blobs.Blob import Blob
     
 Putting a Blob into a Connection works like any other Persistent object:
 
-    >>> connection1 = database.open()
-    >>> root1 = connection1.root()
-    >>> from ZODB.Blobs.Blob import Blob
     >>> blob1 = Blob()
     >>> blob1.open('w').write('this is blob 1')
     >>> root1['blob1'] = blob1
     >>> transaction.commit()
 
+Aborting a transaction involving a blob write cleans up uncommitted
+file data:
+
+    >>> dead_blob = Blob()
+    >>> dead_blob.open('w').write('this is a dead blob')
+    >>> root1['dead_blob'] = dead_blob
+    >>> fname = dead_blob._p_blob_uncommitted
+    >>> import os
+    >>> os.path.exists(fname)
+    True
+    >>> transaction.abort()
+    >>> os.path.exists(fname)
+    False
+
 Opening a blob gives us a filehandle.  Getting data out of the
 resulting filehandle is accomplished via the filehandle's read method:
 
@@ -157,8 +171,7 @@
         ...
     ConflictError: database conflict error (oid 0x01, class ZODB.Blobs.Blob.Blob)
 
-While we are testing this, we don't need the storage directory and databases
-anymore:
+We don't need the storage directory and databases anymore:
 
     >>> import shutil
     >>> shutil.rmtree(blob_dir)



More information about the Zodb-checkins mailing list