Revision 1993fea9
b/docs/source/devguide.rst | ||
---|---|---|
596 | 596 |
Return Code Description |
597 | 597 |
=========================== ============================== |
598 | 598 |
201 (Created) The object has been created |
599 |
409 (Conflict) The object can not be created from the provided hashmap, or there are conflicting permissions (a list of missing hashes, or a conflicting sharing path will be included in the reply - in JSON format) |
|
599 | 600 |
411 (Length Required) Missing ``Content-Length`` or ``Content-Type`` in the request |
600 | 601 |
422 (Unprocessable Entity) The MD5 checksum of the data written to the storage system does not match the (optionally) supplied ETag value |
601 | 602 |
=========================== ============================== |
... | ... | |
626 | 627 |
Return Code Description |
627 | 628 |
=========================== ============================== |
628 | 629 |
201 (Created) The object has been created |
630 |
409 (Conflict) There are conflicting permissions (a conflicting sharing path will be included in the reply - in JSON format) |
|
629 | 631 |
=========================== ============================== |
630 | 632 |
|
631 | 633 |
|
... | ... | |
692 | 694 |
=========================== ============================== |
693 | 695 |
202 (Accepted) The request has been accepted (not a data update) |
694 | 696 |
204 (No Content) The request succeeded (data updated) |
697 |
409 (Conflict) There are conflicting permissions (a conflicting sharing path will be included in the reply - in JSON format) |
|
695 | 698 |
411 (Length Required) Missing ``Content-Length`` in the request |
696 | 699 |
416 (Range Not Satisfiable) The supplied range is invalid |
697 | 700 |
=========================== ============================== |
b/pithos/api/functions.py | ||
---|---|---|
650 | 650 |
if etag and parse_etags(etag)[0].lower() != meta['hash']: |
651 | 651 |
raise UnprocessableEntity('Object ETag does not match') |
652 | 652 |
|
653 |
payload = '' |
|
654 |
code = 201 |
|
655 | 653 |
try: |
656 | 654 |
backend.update_object_hashmap(request.user, v_account, v_container, v_object, size, hashmap, meta, True, permissions) |
657 | 655 |
except NotAllowedError: |
658 | 656 |
raise Unauthorized('Access denied') |
659 | 657 |
except IndexError, e: |
660 |
payload = json.dumps(e.data) |
|
661 |
code = 409 |
|
658 |
raise Conflict(json.dumps(e.data)) |
|
662 | 659 |
except NameError: |
663 | 660 |
raise ItemNotFound('Container does not exist') |
664 | 661 |
except ValueError: |
665 | 662 |
raise BadRequest('Invalid sharing header') |
666 |
except AttributeError: |
|
667 |
raise Conflict('Sharing already set above or below this path in the hierarchy')
|
|
663 |
except AttributeError, e:
|
|
664 |
raise Conflict(json.dumps(e.data))
|
|
668 | 665 |
if public is not None: |
669 | 666 |
try: |
670 | 667 |
backend.update_object_public(request.user, v_account, v_container, v_object, public) |
... | ... | |
673 | 670 |
except NameError: |
674 | 671 |
raise ItemNotFound('Object does not exist') |
675 | 672 |
|
676 |
response = HttpResponse(content=payload, status=code)
|
|
673 |
response = HttpResponse(status=201)
|
|
677 | 674 |
response['ETag'] = meta['hash'] |
678 | 675 |
return response |
679 | 676 |
|
... | ... | |
754 | 751 |
raise ItemNotFound('Object does not exist') |
755 | 752 |
except ValueError: |
756 | 753 |
raise BadRequest('Invalid sharing header') |
757 |
except AttributeError: |
|
758 |
raise Conflict('Sharing already set above or below this path in the hierarchy')
|
|
754 |
except AttributeError, e:
|
|
755 |
raise Conflict(json.dumps(e.data))
|
|
759 | 756 |
if public is not None: |
760 | 757 |
try: |
761 | 758 |
backend.update_object_public(request.user, v_account, v_container, v_object, public) |
... | ... | |
827 | 824 |
raise ItemNotFound('Container does not exist') |
828 | 825 |
except ValueError: |
829 | 826 |
raise BadRequest('Invalid sharing header') |
830 |
except AttributeError: |
|
831 |
raise Conflict('Sharing already set above or below this path in the hierarchy')
|
|
827 |
except AttributeError, e:
|
|
828 |
raise Conflict(json.dumps(e.data))
|
|
832 | 829 |
if public is not None: |
833 | 830 |
try: |
834 | 831 |
backend.update_object_public(request.user, v_account, v_container, v_object, public) |
b/pithos/api/util.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
from django.conf import settings |
41 | 41 |
from django.http import HttpResponse |
42 |
from django.utils import simplejson as json |
|
42 | 43 |
from django.utils.http import http_date, parse_etags |
43 | 44 |
|
44 | 45 |
from pithos.api.compat import parse_http_date_safe, parse_http_date |
... | ... | |
258 | 259 |
raise ItemNotFound('Container or object does not exist') |
259 | 260 |
except ValueError: |
260 | 261 |
raise BadRequest('Invalid sharing header') |
261 |
except AttributeError: |
|
262 |
raise Conflict('Sharing already set above or below this path in the hierarchy')
|
|
262 |
except AttributeError, e:
|
|
263 |
raise Conflict(json.dumps(e.data))
|
|
263 | 264 |
if public is not None: |
264 | 265 |
try: |
265 | 266 |
backend.update_object_public(request.user, v_account, v_container, v_object, public) |
... | ... | |
666 | 667 |
def render_fault(request, fault): |
667 | 668 |
if settings.DEBUG or settings.TEST: |
668 | 669 |
fault.details = format_exc(fault) |
669 |
|
|
670 |
|
|
670 | 671 |
request.serialization = 'text' |
671 | 672 |
data = '\n'.join((fault.message, fault.details)) + '\n' |
672 | 673 |
response = HttpResponse(data, status=fault.code) |
b/pithos/backends/simple.py | ||
---|---|---|
458 | 458 |
self._put_version(path, user, 0, 1) |
459 | 459 |
sql = 'delete from permissions where name = ?' |
460 | 460 |
self.con.execute(sql, (path,)) |
461 |
sql = 'delete from public where name = ?' |
|
462 |
self.con.execute(sql, (path,)) |
|
461 | 463 |
self.con.commit() |
462 | 464 |
|
463 | 465 |
def list_versions(self, user, account, container, name): |
... | ... | |
694 | 696 |
sql = '''select name from permissions |
695 | 697 |
where name != ? and (name like ? or ? like name || ?)''' |
696 | 698 |
c = self.con.execute(sql, (path, path + '%', path, '%')) |
697 |
rows = c.fetchall() |
|
698 |
if rows: |
|
699 |
raise AttributeError('Permissions already set') |
|
699 |
row = c.fetchone() |
|
700 |
if row: |
|
701 |
ae = AttributeError() |
|
702 |
ae.data = row[0] |
|
703 |
raise ae |
|
700 | 704 |
|
701 | 705 |
# Format given permissions. |
702 | 706 |
if len(permissions) == 0: |
... | ... | |
803 | 807 |
self.con.execute(sql, (path,)) |
804 | 808 |
sql = '''delete from versions where name = ?''' |
805 | 809 |
self.con.execute(sql, (path,)) |
806 |
sql = '''delete from permissions where name like ?''' |
|
807 |
self.con.execute(sql, (path + '%',)) # Redundant. |
|
808 | 810 |
self.con.commit() |
Also available in: Unified diff