Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
7d94c068
Commit
7d94c068
authored
Jun 11, 2013
by
Sofia Papagiannaki
Browse files
pithos: refine error handling in object_read view
parent
96789733
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-pithos-app/pithos/api/util.py
View file @
7d94c068
...
...
@@ -35,7 +35,7 @@ from functools import wraps
from
datetime
import
datetime
from
urllib
import
quote
,
unquote
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
,
Http404
,
HttpResponseForbidden
from
django.template.loader
import
render_to_string
from
django.utils
import
simplejson
as
json
from
django.utils.http
import
http_date
,
parse_etags
...
...
@@ -1113,11 +1113,13 @@ def view_method():
request
.
META
[
'HTTP_X_AUTH_TOKEN'
]
=
get_token_from_cookie
(
request
)
# Get the response object
response
=
func
(
request
,
*
args
,
**
kwargs
)
# TODO: support additional success codes
if
response
.
status_code
==
200
:
return
response
elif
response
.
status_code
==
404
:
raise
Http404
()
elif
response
.
status_code
in
[
401
,
403
]:
return
HttpResponseForbidden
()
else
:
# TODO: raise more specific exceptions
raise
Exception
()
raise
Exception
(
response
)
return
wrapper
return
decorator
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment