SVN: ZODB/trunk/src/ZODB/Connection.py Make sure the temporary savepoint storage is closed properly.

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <[email protected]>
Log message for revision 114663:
  Make sure the temporary savepoint storage is closed properly.
  

Changed:
  U   ZODB/trunk/src/ZODB/Connection.py

-=-
Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py	2010-07-12 22:01:52 UTC (rev 114662)
+++ ZODB/trunk/src/ZODB/Connection.py	2010-07-12 22:02:48 UTC (rev 114663)
@@ -1099,35 +1099,38 @@
         src = self._savepoint_storage
         self._storage = self._normal_storage
         self._savepoint_storage = None
+        try:
+            self._log.debug("Committing savepoints of size %s", src.getSize())
+            oids = src.index.keys()
 
-        self._log.debug("Committing savepoints of size %s", src.getSize())
-        oids = src.index.keys()
+            # Copy invalidating and creating info from temporary storage:
+            self._modified.extend(oids)
+            self._creating.update(src.creating)
 
-        # Copy invalidating and creating info from temporary storage:
-        self._modified.extend(oids)
-        self._creating.update(src.creating)
-
-        for oid in oids:
-            data, serial = src.load(oid, src)
-            obj = self._cache.get(oid, None)
-            if obj is not None:
-                self._cache.update_object_size_estimation(obj._p_oid, len(data))
-                obj._p_estimated_size = len(data)
-            if isinstance(self._reader.getGhost(data), Blob):
-                blobfilename = src.loadBlob(oid, serial)
-                s = self._storage.storeBlob(oid, serial, data, blobfilename,
+            for oid in oids:
+                data, serial = src.load(oid, src)
+                obj = self._cache.get(oid, None)
+                if obj is not None:
+                    self._cache.update_object_size_estimation(
+                        obj._p_oid, len(data))
+                    obj._p_estimated_size = len(data)
+                if isinstance(self._reader.getGhost(data), Blob):
+                    blobfilename = src.loadBlob(oid, serial)
+                    s = self._storage.storeBlob(
+                        oid, serial, data, blobfilename,
+                        '', transaction)
+                    # we invalidate the object here in order to ensure
+                    # that that the next attribute access of its name
+                    # unghostify it, which will cause its blob data
+                    # to be reattached "cleanly"
+                    self.invalidate(None, (oid, ))
+                else:
+                    s = self._storage.store(oid, serial, data,
                                             '', transaction)
-                # we invalidate the object here in order to ensure
-                # that that the next attribute access of its name
-                # unghostify it, which will cause its blob data
-                # to be reattached "cleanly"
-                self.invalidate(None, (oid, ))
-            else:
-                s = self._storage.store(oid, serial, data,
-                                        '', transaction)
 
-            self._handle_serial(oid, s, change=False)
-        src.close()
+                self._handle_serial(oid, s, change=False)
+        finally:
+            src.close()
 
     def _abort_savepoint(self):
         """Discard all savepoint data."""
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.