Revision d2d09227
b/snf-pithos-app/pithos/api/util.py | ||
---|---|---|
35 | 35 |
from datetime import datetime |
36 | 36 |
from urllib import quote, unquote |
37 | 37 |
|
38 |
from django.http import HttpResponse |
|
38 |
from django.http import HttpResponse, Http404, HttpResponseForbidden
|
|
39 | 39 |
from django.template.loader import render_to_string |
40 | 40 |
from django.utils import simplejson as json |
41 | 41 |
from django.utils.http import http_date, parse_etags |
... | ... | |
1113 | 1113 |
request.META['HTTP_X_AUTH_TOKEN'] = get_token_from_cookie(request) |
1114 | 1114 |
# Get the response object |
1115 | 1115 |
response = func(request, *args, **kwargs) |
1116 |
# TODO: support additional success codes |
|
1117 | 1116 |
if response.status_code == 200: |
1118 | 1117 |
return response |
1118 |
elif response.status_code == 404: |
|
1119 |
raise Http404() |
|
1120 |
elif response.status_code in [401, 403]: |
|
1121 |
return HttpResponseForbidden() |
|
1119 | 1122 |
else: |
1120 |
# TODO: raise more specific exceptions |
|
1121 |
raise Exception() |
|
1123 |
raise Exception(response) |
|
1122 | 1124 |
return wrapper |
1123 | 1125 |
return decorator |
Also available in: Unified diff