Revision e8886082 pithos/api/functions.py

b/pithos/api/functions.py
348 348
        else:
349 349
            try:
350 350
                meta = backend.get_object_meta(request.user, v_account, v_container, x[0], x[1])
351
                permissions = backend.get_object_permissions(request.user, v_account, v_container, x[0])
351
                if until is None:
352
                    permissions = backend.get_object_permissions(request.user, v_account, v_container, x[0])
353
                else:
354
                    permissions = None
352 355
            except NameError:
353 356
                pass
354 357
            if permissions:
......
373 376
    version = get_int_parameter(request, 'version')
374 377
    try:
375 378
        meta = backend.get_object_meta(request.user, v_account, v_container, v_object, version)
376
        permissions = backend.get_object_permissions(request.user, v_account, v_container, v_object)
379
        if version is None:
380
            permissions = backend.get_object_permissions(request.user, v_account, v_container, v_object)
381
        else:
382
            permissions = None
377 383
    except NameError:
378 384
        raise ItemNotFound('Object does not exist')
379 385
    except IndexError:
......
399 405
    #                       notModified (304)
400 406
    
401 407
    version = get_int_parameter(request, 'version')
402
    version_list = False
408
    
409
    # Reply with the version list. Do this first, as the object may be deleted.
403 410
    if version is None and request.GET.get('version') == 'list':
404
        version_list = True
411
        if request.serialization == 'text':
412
            raise BadRequest('No format specified for version list.')
413
        
414
        d = {'versions': backend.list_versions(request.user, v_account, v_container, v_object)}
415
        if request.serialization == 'xml':
416
            d['object'] = v_object
417
            data = render_to_string('versions.xml', d)
418
        elif request.serialization  == 'json':
419
            data = json.dumps(d)
420
        
421
        response = HttpResponse(data, status=200)
422
        response['Content-Length'] = len(data)
423
        return response
424
    
405 425
    try:
406 426
        meta = backend.get_object_meta(request.user, v_account, v_container, v_object, version)
407
        permissions = backend.get_object_permissions(request.user, v_account, v_container, v_object)
427
        if version is None:
428
            permissions = backend.get_object_permissions(request.user, v_account, v_container, v_object)
429
        else:
430
            permissions = None
408 431
    except NameError:
409 432
        raise ItemNotFound('Object does not exist')
410 433
    except IndexError:
......
423 446
        response['ETag'] = meta['hash']
424 447
        return response
425 448
    
426
    # Reply with the version list.
427
    if version_list:
428
        if request.serialization == 'text':
429
            raise BadRequest('No format specified for version list.')
430
        
431
        d = {'versions': backend.list_versions(request.user, v_account, v_container, v_object)}
432
        if request.serialization == 'xml':
433
            d['object'] = v_object
434
            data = render_to_string('versions.xml', d)
435
        elif request.serialization  == 'json':
436
            data = json.dumps(d)
437
        
438
        response = HttpResponse(data, status=200)
439
        put_object_meta(response, meta)
440
        response['Content-Length'] = len(data)
441
        return response
442
    
443 449
    sizes = []
444 450
    hashmaps = []
445 451
    if 'X-Object-Manifest' in meta:

Also available in: Unified diff