Permalink
Browse files

Correctly handle rollback all DatabaseErrors

  • Loading branch information...
1 parent e246e66 commit e21db43bf4339f49f8214e398c0e2402036c6d9d @cnorthwood cnorthwood committed Jul 29, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 molly/batch_processing/models.py
@@ -5,7 +5,7 @@
from datetime import datetime
from StringIO import StringIO
-from django.db import models, IntegrityError, transaction
+from django.db import models, DatabaseError, transaction
from molly.conf import all_apps, app_by_local_name
@@ -73,8 +73,8 @@ def run(self, tee_to_stdout=False):
method = getattr(provider, self.method_name)
self.metadata = method(self.metadata, output)
- except Exception, e:
- if isinstance(e, IntegrityError):
+ except Exception as e:
+ if isinstance(e, DatabaseError):
transaction.rollback()
if output.getvalue():
output.write("\n\n")

0 comments on commit e21db43

Please sign in to comment.