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
e264d084
Commit
e264d084
authored
Apr 15, 2013
by
Christos Stavrakakis
Browse files
Make 'api_method' to take astakos_url as argument
parent
3e941c3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
snf-django-lib/snf_django/lib/api/__init__.py
View file @
e264d084
...
...
@@ -60,7 +60,7 @@ def get_token(request):
def
api_method
(
http_method
=
None
,
token_required
=
True
,
user_required
=
True
,
logger
=
None
,
format_allowed
=
True
):
logger
=
None
,
format_allowed
=
True
,
astakos_url
=
None
):
"""Decorator function for views that implement an API method."""
if
not
logger
:
logger
=
log
...
...
@@ -89,8 +89,9 @@ def api_method(http_method=None, token_required=True, user_required=True,
# Authenticate
if
user_required
:
assert
(
token_required
),
"Can not get user without token"
astakos
=
astakos_url
or
settings
.
ASTAKOS_URL
try
:
astakos
=
AstakosClient
(
settings
.
ASTAKOS_URL
,
astakos
=
AstakosClient
(
astakos
,
use_pool
=
True
,
logger
=
logger
)
user_info
=
astakos
.
get_user_info
(
token
)
...
...
@@ -166,7 +167,7 @@ def update_response_headers(request, response):
raise
ValueError
(
"Unknown serialization format '%s'"
%
serialization
)
if
settings
.
DEBUG
or
settings
.
TEST
:
if
settings
.
DEBUG
or
getattr
(
settings
,
"
TEST
"
,
False
)
:
response
[
"Date"
]
=
format_date_time
(
time
())
if
not
response
.
has_header
(
"Content-Length"
):
...
...
@@ -182,7 +183,7 @@ def update_response_headers(request, response):
def
render_fault
(
request
,
fault
):
"""Render an API fault to an HTTP response."""
# If running in debug mode add exception information to fault details
if
settings
.
DEBUG
or
settings
.
TEST
:
if
settings
.
DEBUG
or
getattr
(
settings
,
"
TEST
"
,
False
)
:
fault
.
details
=
format_exc
()
try
:
...
...
snf-pithos-app/pithos/api/util.py
View file @
e264d084
...
...
@@ -1015,7 +1015,8 @@ def api_method(http_method=None, user_required=True, logger=None,
format_allowed
=
False
):
def
decorator
(
func
):
@
api
.
api_method
(
http_method
=
http_method
,
user_required
=
user_required
,
logger
=
logger
,
format_allowed
=
format_allowed
)
logger
=
logger
,
format_allowed
=
format_allowed
,
astakos_url
=
ASTAKOS_URL
)
@
wraps
(
func
)
def
wrapper
(
request
,
*
args
,
**
kwargs
):
# The args variable may contain up to (account, container, object).
...
...
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