Revision 23b41f6f snf-pithos-app/pithos/api/util.py
b/snf-pithos-app/pithos/api/util.py | ||
---|---|---|
1088 | 1088 |
if len(args) > 2 and len(args[2]) > 1024: |
1089 | 1089 |
raise faults.BadRequest('Object name too large.') |
1090 | 1090 |
|
1091 |
success_status = False |
|
1092 |
try: |
|
1091 |
with get_backend() as backend: |
|
1093 | 1092 |
# Add a PithosBackend as attribute of the request object |
1094 |
request.backend = get_backend()
|
|
1095 |
request.backend.pre_exec(lock_container_path)
|
|
1093 |
request.backend = backend
|
|
1094 |
request.backend.lock_container_path = lock_container_path
|
|
1096 | 1095 |
|
1097 | 1096 |
# Many API method expect thet X-Auth-Token in request,token |
1098 | 1097 |
request.token = request.x_auth_token |
... | ... | |
1100 | 1099 |
response = func(request, *args, **kwargs) |
1101 | 1100 |
update_response_headers(request, response) |
1102 | 1101 |
|
1103 |
success_status = True |
|
1104 | 1102 |
return response |
1105 |
finally: |
|
1106 |
# Always close PithosBackend connection |
|
1107 |
if getattr(request, "backend", None) is not None: |
|
1108 |
request.backend.post_exec(success_status) |
|
1109 |
request.backend.close() |
|
1110 | 1103 |
return wrapper |
1111 | 1104 |
return decorator |
1112 | 1105 |
|
Also available in: Unified diff