Ignore IntegrityError when we're attempting to save a API doc

This commit is contained in:
2011-06-29 12:09:33 +01:00
parent c37c291cf2
commit 699108e513

View File

@@ -4,7 +4,7 @@ import urllib, urllib2
from hashlib import sha1
from datetime import datetime, timedelta
from xml.dom import minidom
from django.db import models
from django.db import models, IntegrityError
from django.conf import settings
from eve_proxy.exceptions import *
@@ -105,7 +105,11 @@ class CachedDocumentManager(models.Manager):
# If we have a error in the ignored error list use the cached doc, otherwise return the new doc
if not error or not error in ROLLBACK_ERRORS:
doc.save()
try:
doc.save()
except IntegrityError:
# Ignore IntegrityError for this instance, just reload the doc from store
pass
doc = self.get(pk=doc.pk)
elif error in ROLLBACK_ERRORS and not created:
logger.info("API Error %s encountered" % error, extra={'data': {'api-url': url, 'error': error, 'document': doc.body}})