[Checkins] SVN: ZODB/branches/blob-merge-branch/src/ZODB/Blobs/ Windows compatibility: Closing filehandles, part 2. The

Wolfgang Schnerring wosc at wosc.de
Mon Sep 25 05:44:30 EDT 2006


Log message for revision 70361:
  Windows compatibility: Closing filehandles, part 2. The
  BlobDataManager needs to close all filehandles of the Blob before the
  Connection commits, so the files can then safely be renamed.
  
  Refactored BlobDataManager to use tpc_* protocol instead of
  zodb-4-style protocol.
  

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

-=-
Modified: ZODB/branches/blob-merge-branch/src/ZODB/Blobs/Blob.py
===================================================================
--- ZODB/branches/blob-merge-branch/src/ZODB/Blobs/Blob.py	2006-09-25 09:35:35 UTC (rev 70360)
+++ ZODB/branches/blob-merge-branch/src/ZODB/Blobs/Blob.py	2006-09-25 09:44:29 UTC (rev 70361)
@@ -179,7 +179,7 @@
 
 
 class BlobDataManager:
-    """Special data managerto handle transaction boundaries for blobs.
+    """Special data manager to handle transaction boundaries for blobs.
 
     Blobs need some special care-taking on transaction boundaries. As
 
@@ -220,17 +220,13 @@
     # IDataManager
 
     def tpc_begin(self, transaction):
-        pass
+        if self.prepared:
+            raise TypeError('Already prepared')
+        self._checkTransaction(transaction)
+        self.prepared = True
+        self.transaction = transaction
+        self.fhrefs.map(lambda fhref: fhref.close())
 
-    def tpc_abort(self, transaction):
-        pass
-
-    def tpc_finish(self, transaction):
-        pass
-
-    def tpc_vote(self, transaction):
-        pass
-
     def commit(self, transaction):
         if not self.prepared:
             raise TypeError('Not prepared to commit')
@@ -239,9 +235,11 @@
         self.prepared = False
 
         self.blob._p_blob_clear() 
-        self.fhrefs.map(lambda fhref: fhref.close())
 
     def abort(self, transaction):
+        self.tpc_abort(transaction)
+
+    def tpc_abort(self, transaction):
         self._checkTransaction(transaction)
         if self.transaction is not None:
             self.transaction = None
@@ -249,16 +247,15 @@
 
         self._remove_uncommitted_data()
 
+    def tpc_finish(self, transaction):
+        pass
+
+    def tpc_vote(self, transaction):
+        pass
+
     def sortKey(self):
         return self.sortkey
 
-    def prepare(self, transaction):
-        if self.prepared:
-            raise TypeError('Already prepared')
-        self._checkTransaction(transaction)
-        self.prepared = True
-        self.transaction = transaction
-
     def _checkTransaction(self, transaction):
         if (self.transaction is not None and
             self.transaction is not transaction):

Modified: ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt
===================================================================
--- ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt	2006-09-25 09:35:35 UTC (rev 70360)
+++ ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/transaction.txt	2006-09-25 09:44:29 UTC (rev 70361)
@@ -231,7 +231,7 @@
     >>> savepoint = transaction.savepoint()             # doctest: +ELLIPSIS
     Traceback (most recent call last):
         ...
-    TypeError: ('Savepoints unsupported', <transaction._transaction.DataManagerAdapter object at 0x...>)
+    TypeError: ('Savepoints unsupported', <ZODB.Blobs.Blob.BlobDataManager instance at 0x...>)
 
 
 Teardown



More information about the Checkins mailing list