Revision 65bbcd43 snf-pithos-app/pithos/api/public.py

b/snf-pithos-app/pithos/api/public.py
1
# Copyright 2011-2012 GRNET S.A. All rights reserved.
1
# Copyright 2011-2013 GRNET S.A. All rights reserved.
2 2
#
3 3
# Redistribution and use in source and binary forms, with or
4 4
# without modification, are permitted provided that the following
......
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
import logging
35

  
36 34
from django.http import HttpResponse
37 35
from django.views.decorators.csrf import csrf_exempt
38 36

  
39
from synnefo.lib.astakos import get_user
37
from snf_django.lib import api
40 38
from snf_django.lib.api import faults
41 39

  
42 40
from pithos.api.util import (put_object_headers, update_manifest_meta,
......
44 42
                             validate_matching_preconditions,
45 43
                             object_data_response, api_method,
46 44
                             split_container_object_string)
47
from pithos.api.settings import AUTHENTICATION_URL, AUTHENTICATION_USERS
48

  
49 45

  
46
import logging
50 47
logger = logging.getLogger(__name__)
51 48

  
52 49

  
53 50
@csrf_exempt
54 51
def public_demux(request, v_public):
55
    get_user(request, AUTHENTICATION_URL, AUTHENTICATION_USERS)
56 52
    if request.method == 'HEAD':
57 53
        return public_meta(request, v_public)
58 54
    elif request.method == 'GET':
59 55
        return public_read(request, v_public)
60 56
    else:
61
        return method_not_allowed(request)
57
        return api.method_not_allowed(request)
62 58

  
63 59

  
64
@api_method('HEAD', user_required=False)
60
@api_method(http_method="HEAD", user_required=False, logger=logger)
65 61
def public_meta(request, v_public):
66 62
    # Normal Response Codes: 204
67 63
    # Error Response Codes: internalServerError (500),
......
89 85
    return response
90 86

  
91 87

  
92
@api_method('GET', user_required=False)
88
@api_method(http_method="GET", user_required=False, logger=logger)
93 89
def public_read(request, v_public):
94 90
    # Normal Response Codes: 200, 206
95 91
    # Error Response Codes: internalServerError (500),
......
139 135
        try:
140 136
            for x in objects:
141 137
                s, h = request.backend.get_object_hashmap(request.user_uniq,
142
                                                          v_account, src_container, x[0], x[1])
138
                                                          v_account,
139
                                                          src_container,
140
                                                          x[0], x[1])
143 141
                sizes.append(s)
144 142
                hashmaps.append(h)
145 143
        except:
......
161 159
        meta['Content-Disposition'] = 'attachment; filename=%s' % (name,)
162 160

  
163 161
    return object_data_response(request, sizes, hashmaps, meta, True)
164

  
165

  
166
@api_method(user_required=False)
167
def method_not_allowed(request, **v_args):
168
    raise faults.ItemNotFound('Object does not exist')

Also available in: Unified diff