server/sources/native.py
changeset 2618 ff9b0d5bd884
parent 2611 0557f25682da
child 2619 535bc210f799
--- a/server/sources/native.py	Sat Aug 01 01:13:39 2009 +0200
+++ b/server/sources/native.py	Sat Aug 01 01:16:19 2009 +0200
@@ -432,7 +432,7 @@
             sql = self.sqlgen.delete('%s_relation' % rtype, attrs)
         self.doexec(session, sql, attrs)
 
-    def doexec(self, session, query, args=None):
+    def doexec(self, session, query, args=None, rollback=True):
         """Execute a query.
         it's a function just so that it shows up in profiling
         """
@@ -445,11 +445,12 @@
         except Exception, ex:
             self.critical("sql: %r\n args: %s\ndbms message: %r",
                           query, args, ex.args[0])
-            try:
-                session.pool.connection(self.uri).rollback()
-                self.critical('transaction has been rollbacked')
-            except:
-                pass
+            if rollback:
+                try:
+                    session.pool.connection(self.uri).rollback()
+                    self.critical('transaction has been rollbacked')
+                except:
+                    pass
             raise
         return cursor