use some transactions

This commit is contained in:
j 2011-10-29 16:59:12 +02:00
parent 88b4d9f62f
commit 21ab5fa451

View file

@ -13,7 +13,7 @@ import uuid
import unicodedata import unicodedata
from urllib import quote from urllib import quote
from django.db import models from django.db import models, transaction
from django.db.models import Count, Q, Sum from django.db.models import Count, Q, Sum
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.conf import settings from django.conf import settings
@ -518,6 +518,7 @@ class Item(models.Model):
else: else:
ItemFind.objects.filter(item=self, key=key).delete() ItemFind.objects.filter(item=self, key=key).delete()
with transaction.commit_on_success():
for key in settings.CONFIG['itemKeys']: for key in settings.CONFIG['itemKeys']:
i = key['id'] i = key['id']
if i == 'title': if i == 'title':
@ -1043,6 +1044,7 @@ class Item(models.Model):
return icon return icon
def load_subtitles(self): def load_subtitles(self):
with transaction.commit_on_success():
layer = Layer.objects.get(name='subtitles') layer = Layer.objects.get(name='subtitles')
Annotation.objects.filter(layer=layer,item=self).delete() Annotation.objects.filter(layer=layer,item=self).delete()
offset = 0 offset = 0