Revision af7bb62f

b/docs/source/devguide.rst
36 36
\                          Always reply with the MD5 in the ETag.
37 37
\                          Note that ``/login`` will only work if an external authentication system is defined.
38 38
\                          Include option to ignore Content-Type on ``COPY``/``MOVE``.
39
\                          Use format parameter for conflict (409) replies.
39
\                          Use format parameter for conflict (409) and uploaded hash list (container level) replies.
40 40
0.7 (Nov 21, 2011)         Suggest upload/download methods using hashmaps.
41 41
\                          Propose syncing algorithm.
42 42
\                          Support cross-account object copy and move.
......
602 602
======================  ============================================
603 603
Request Parameter Name  Value
604 604
======================  ============================================
605
format                  Optional hash list reply type (can be ``json`` or ``xml``)
605 606
update                  Do not replace metadata/policy (no value parameter)
606 607
======================  ============================================
607 608

  
608
No reply content/headers, except when uploading data, where the reply consists of a list of hashes for the blocks received (in a simple text format, with one hash per line).
609
No reply content/headers, except when uploading data, where the reply consists of a list of hashes for the blocks received (in the format specified).
609 610

  
610 611
The operation will overwrite all user defined metadata, except if ``update`` is defined.
611 612
To change policy, include an ``X-Container-Policy-*`` header with the name in the key. If no ``X-Container-Policy-*`` header is present, no changes will be applied to policy. The ``update`` parameter also applies to policy - deleted values will revert to defaults. To delete/revert a specific policy directive, use ``update`` and an empty header value. See container ``PUT`` for a reference of policy directives.
b/pithos/api/functions.py
51 51
    put_object_headers, update_manifest_meta, update_sharing_meta, update_public_meta,
52 52
    validate_modification_preconditions, validate_matching_preconditions, split_container_object_string,
53 53
    copy_or_move_object, get_int_parameter, get_content_length, get_content_range, socket_read_iterator,
54
    SaveToBackendHandler, object_data_response, put_object_block, hashmap_md5, object_conflict_response, api_method)
54
    SaveToBackendHandler, object_data_response, put_object_block, hashmap_md5, simple_list_response, api_method)
55 55
from pithos.backends.base import NotAllowedError, QuotaError
56 56

  
57 57

  
......
376 376
    
377 377
    return HttpResponse(status=ret)
378 378

  
379
@api_method('POST')
379
@api_method('POST', format_allowed=True)
380 380
def container_update(request, v_account, v_container):
381 381
    # Normal Response Codes: 202
382 382
    # Error Response Codes: internalServerError (500),
......
421 421
    
422 422
    response = HttpResponse(status=202)
423 423
    if hashmap:
424
        response.content = '\n'.join(hashmap) + '\n'
424
        response.content = simple_list_response(request, hashmap)
425 425
    return response
426 426

  
427 427
@api_method('DELETE')
......
853 853
    except NotAllowedError:
854 854
        raise Forbidden('Not allowed')
855 855
    except IndexError, e:
856
        raise Conflict(object_conflict_response(request, e.data))
856
        raise Conflict(simple_list_response(request, e.data))
857 857
    except NameError:
858 858
        raise ItemNotFound('Container does not exist')
859 859
    except ValueError:
860 860
        raise BadRequest('Invalid sharing header')
861 861
    except AttributeError, e:
862
        raise Conflict(object_conflict_response(request, e.data))
862
        raise Conflict(simple_list_response(request, e.data))
863 863
    except QuotaError:
864 864
        raise RequestEntityTooLarge('Quota exceeded')
865 865
    if 'ETag' not in meta:
......
1044 1044
            except ValueError:
1045 1045
                raise BadRequest('Invalid sharing header')
1046 1046
            except AttributeError, e:
1047
                raise Conflict(object_conflict_response(request, e.data))
1047
                raise Conflict(simple_list_response(request, e.data))
1048 1048
        if public is not None:
1049 1049
            try:
1050 1050
                request.backend.update_object_public(request.user_uniq, v_account,
......
1190 1190
    except ValueError:
1191 1191
        raise BadRequest('Invalid sharing header')
1192 1192
    except AttributeError, e:
1193
        raise Conflict(object_conflict_response(request, e.data))
1193
        raise Conflict(simple_list_response(request, e.data))
1194 1194
    except QuotaError:
1195 1195
        raise RequestEntityTooLarge('Quota exceeded')
1196 1196
    if public is not None:
/dev/null
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<conflicts>
4
  {% for conflict in conflicts %}
5
  <conflict>{{ conflict }}</conflict>
6
  {% endfor %}
7
</conflicts>
b/pithos/api/templates/items.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<items>
4
  {% for item in items %}
5
  <item>{{ item }}</item>
6
  {% endfor %}
7
</items>
b/pithos/api/util.py
323 323
    except ValueError:
324 324
        raise BadRequest('Invalid sharing header')
325 325
    except AttributeError, e:
326
        raise Conflict(object_conflict_response(request, e.data))
326
        raise Conflict(simple_list_response(request, e.data))
327 327
    except QuotaError:
328 328
        raise RequestEntityTooLarge('Quota exceeded')
329 329
    if public is not None:
......
759 759
        md5.update(data + ('\x00' * pad))
760 760
    return md5.hexdigest().lower()
761 761

  
762
def object_conflict_response(request, l):
762
def simple_list_response(request, l):
763 763
    if request.serialization == 'text':
764 764
        return '\n'.join(l) + '\n'
765 765
    if request.serialization == 'xml':
766
        return render_to_string('conflicts.xml', {'conflicts': l})
766
        return render_to_string('items.xml', {'items': l})
767 767
    if request.serialization == 'json':
768 768
        return json.dumps(l)
769 769

  

Also available in: Unified diff