Return Code Description
=========================== ==============================
201 (Created) The object has been created
+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)
411 (Length Required) Missing ``Content-Length`` or ``Content-Type`` in the request
422 (Unprocessable Entity) The MD5 checksum of the data written to the storage system does not match the (optionally) supplied ETag value
=========================== ==============================
Return Code Description
=========================== ==============================
201 (Created) The object has been created
+409 (Conflict) There are conflicting permissions (a conflicting sharing path will be included in the reply - in JSON format)
=========================== ==============================
=========================== ==============================
202 (Accepted) The request has been accepted (not a data update)
204 (No Content) The request succeeded (data updated)
+409 (Conflict) There are conflicting permissions (a conflicting sharing path will be included in the reply - in JSON format)
411 (Length Required) Missing ``Content-Length`` in the request
416 (Range Not Satisfiable) The supplied range is invalid
=========================== ==============================
if etag and parse_etags(etag)[0].lower() != meta['hash']:
raise UnprocessableEntity('Object ETag does not match')
- payload = ''
- code = 201
try:
backend.update_object_hashmap(request.user, v_account, v_container, v_object, size, hashmap, meta, True, permissions)
except NotAllowedError:
raise Unauthorized('Access denied')
except IndexError, e:
- payload = json.dumps(e.data)
- code = 409
+ raise Conflict(json.dumps(e.data))
except NameError:
raise ItemNotFound('Container does not exist')
except ValueError:
raise BadRequest('Invalid sharing header')
- except AttributeError:
- raise Conflict('Sharing already set above or below this path in the hierarchy')
+ except AttributeError, e:
+ raise Conflict(json.dumps(e.data))
if public is not None:
try:
backend.update_object_public(request.user, v_account, v_container, v_object, public)
except NameError:
raise ItemNotFound('Object does not exist')
- response = HttpResponse(content=payload, status=code)
+ response = HttpResponse(status=201)
response['ETag'] = meta['hash']
return response
raise ItemNotFound('Object does not exist')
except ValueError:
raise BadRequest('Invalid sharing header')
- except AttributeError:
- raise Conflict('Sharing already set above or below this path in the hierarchy')
+ except AttributeError, e:
+ raise Conflict(json.dumps(e.data))
if public is not None:
try:
backend.update_object_public(request.user, v_account, v_container, v_object, public)
raise ItemNotFound('Container does not exist')
except ValueError:
raise BadRequest('Invalid sharing header')
- except AttributeError:
- raise Conflict('Sharing already set above or below this path in the hierarchy')
+ except AttributeError, e:
+ raise Conflict(json.dumps(e.data))
if public is not None:
try:
backend.update_object_public(request.user, v_account, v_container, v_object, public)
from django.conf import settings
from django.http import HttpResponse
+from django.utils import simplejson as json
from django.utils.http import http_date, parse_etags
from pithos.api.compat import parse_http_date_safe, parse_http_date
raise ItemNotFound('Container or object does not exist')
except ValueError:
raise BadRequest('Invalid sharing header')
- except AttributeError:
- raise Conflict('Sharing already set above or below this path in the hierarchy')
+ except AttributeError, e:
+ raise Conflict(json.dumps(e.data))
if public is not None:
try:
backend.update_object_public(request.user, v_account, v_container, v_object, public)
def render_fault(request, fault):
if settings.DEBUG or settings.TEST:
fault.details = format_exc(fault)
-
+
request.serialization = 'text'
data = '\n'.join((fault.message, fault.details)) + '\n'
response = HttpResponse(data, status=fault.code)
self._put_version(path, user, 0, 1)
sql = 'delete from permissions where name = ?'
self.con.execute(sql, (path,))
+ sql = 'delete from public where name = ?'
+ self.con.execute(sql, (path,))
self.con.commit()
def list_versions(self, user, account, container, name):
sql = '''select name from permissions
where name != ? and (name like ? or ? like name || ?)'''
c = self.con.execute(sql, (path, path + '%', path, '%'))
- rows = c.fetchall()
- if rows:
- raise AttributeError('Permissions already set')
+ row = c.fetchone()
+ if row:
+ ae = AttributeError()
+ ae.data = row[0]
+ raise ae
# Format given permissions.
if len(permissions) == 0:
self.con.execute(sql, (path,))
sql = '''delete from versions where name = ?'''
self.con.execute(sql, (path,))
- sql = '''delete from permissions where name like ?'''
- self.con.execute(sql, (path + '%',)) # Redundant.
self.con.commit()