Add transaction rollback

This commit is contained in:
Roberto Rosario
2012-02-06 14:56:27 -04:00
parent 248a5ea82d
commit eef1114be2
3 changed files with 14 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.core.exceptions import ValidationError
from django.db import transaction
from django.db.utils import DatabaseError
from converter.api import get_available_transformations_choices
from converter.literals import DIMENSION_SEPARATOR
@@ -93,7 +94,7 @@ class BaseModel(models.Model):
document = Document()
if document_type:
document.document_type = document_type
document.save()
document.save()
apply_default_acls(document, user)
@@ -119,7 +120,8 @@ class BaseModel(models.Model):
new_version = document.new_version(file=file_object, **new_version_data)
except Exception:
# Don't leave the database in a broken state
document.delete()
# document.delete()
transaction.rollback()
raise
if filename: