Revision 6b6b6c1e pithos/api/util.py
b/pithos/api/util.py | ||
---|---|---|
41 | 41 |
|
42 | 42 |
from django.conf import settings |
43 | 43 |
from django.http import HttpResponse |
44 |
from django.template.loader import render_to_string |
|
44 | 45 |
from django.utils import simplejson as json |
45 | 46 |
from django.utils.http import http_date, parse_etags |
46 | 47 |
from django.utils.encoding import smart_unicode, smart_str |
... | ... | |
322 | 323 |
except ValueError: |
323 | 324 |
raise BadRequest('Invalid sharing header') |
324 | 325 |
except AttributeError, e: |
325 |
raise Conflict('\n'.join(e.data) + '\n')
|
|
326 |
raise Conflict(object_conflict_response(request, e.data))
|
|
326 | 327 |
except QuotaError: |
327 | 328 |
raise RequestEntityTooLarge('Quota exceeded') |
328 | 329 |
if public is not None: |
... | ... | |
758 | 759 |
md5.update(data + ('\x00' * pad)) |
759 | 760 |
return md5.hexdigest().lower() |
760 | 761 |
|
762 |
def object_conflict_response(request, l): |
|
763 |
if request.serialization == 'text': |
|
764 |
return '\n'.join(l) + '\n' |
|
765 |
if request.serialization == 'xml': |
|
766 |
return render_to_string('conflicts.xml', {'conflicts': l}) |
|
767 |
if request.serialization == 'json': |
|
768 |
return json.dumps(l) |
|
769 |
|
|
761 | 770 |
def get_backend(): |
762 | 771 |
backend = connect_backend(db_module=settings.BACKEND_DB_MODULE, |
763 | 772 |
db_connection=settings.BACKEND_DB_CONNECTION, |
Also available in: Unified diff