Title: [commits] (morgen) [16039] Fix for bug 11528 (Traceback when canceling a "collections and settings" export), r=stearns
Revision
16039
Author
morgen
Date
2007-12-04 09:55:12 -0800 (Tue, 04 Dec 2007)

Log Message

Fix for bug 11528 (Traceback when canceling a "collections and settings" export), r=stearns

Thanks to Bryan for pointing out that exception handlers always run before the
finally clause despite how one misinterprets the documentation.

Modified Paths

Diff

Modified: trunk/chandler/parcels/osaf/dumpreload.py (16038 => 16039)

--- trunk/chandler/parcels/osaf/dumpreload.py	2007-12-04 05:58:30 UTC (rev 16038)
+++ trunk/chandler/parcels/osaf/dumpreload.py	2007-12-04 17:55:12 UTC (rev 16039)
@@ -133,39 +133,41 @@
     # XXX before we got here, so the caller should be prepared to handle that.
     output = os.fdopen(os.open(filename, flags, 0600), 'wb')
     try:
-        dump = serializer.dumper(output)
+        try:
+            dump = serializer.dumper(output)
 
-        if activity:
-            count = len(aliases)
-            activity.update(msg=_(u"Exporting %(total)d records") % {'total':count}, totalWork=count)
-
-        i = 0
-        for alias in aliases:
-            uuid = trans.getUUIDForAlias(alias)
-            item = rv.findUUID(uuid)
-            for record in trans.exportItem(item):
-                dump(record)
-            i += 1
             if activity:
-                activity.update(msg=_(u"Exported %(number)d of %(total)d items") % \
-                                {'number':i, 'total':count}, work=1)
+                count = len(aliases)
+                activity.update(msg=_(u"Exporting %(total)d records") % {'total':count}, totalWork=count)
 
-        if activity:
-            activity.update(totalWork=None) # we don't know upcoming total work
+            i = 0
+            for alias in aliases:
+                uuid = trans.getUUIDForAlias(alias)
+                item = rv.findUUID(uuid)
+                for record in trans.exportItem(item):
+                    dump(record)
+                i += 1
+                if activity:
+                    activity.update(msg=_(u"Exported %(number)d of %(total)d items") % \
+                                    {'number':i, 'total':count}, work=1)
 
-        for record in trans.finishExport():
             if activity:
-                count += 1
-                activity.update(msg=_(u"Exporting additional record"))
+                activity.update(totalWork=None) # we don't know upcoming total work
 
-            dump(record)
+            for record in trans.finishExport():
+                if activity:
+                    count += 1
+                    activity.update(msg=_(u"Exporting additional record"))
 
-        dump(None)
-        del dump
-    except ActivityAborted:
+                dump(record)
+
+            dump(None)
+            del dump
+        finally:
+            output.close()
+    except:
+        logger.exception("Error during export")
         os.remove(filename)
-    finally:
-        output.close()
 
     if activity:
         activity.update(msg=_(u"Exported %(total)d records") % {'total':count})




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to