Revision 784dcbdb snf-quotaholder-app/quotaholder_django/quotaholder_app/views.py

b/snf-quotaholder-app/quotaholder_django/quotaholder_app/views.py
1
# Copyright 2012 GRNET S.A. All rights reserved.
1
# Copyright 2012, 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
......
33 33

  
34 34

  
35 35
from django.http import HttpResponse
36
from django.db import transaction 
36
from django.db import transaction
37 37
from django.conf import settings
38 38
from synnefo.lib.commissioning import CallError
39 39

  
......
42 42
import json
43 43
from traceback import format_exc
44 44

  
45
import logging
46
logger = logging.getLogger(__name__)
47

  
45 48
try:
46 49
    from django.views.decorators.csrf import csrf_exempt
47 50
except ImportError:
48 51
    def csrf_exempt(func):
49 52
        return func
50 53

  
54

  
51 55
def _get_body(request):
52 56
    body = request.raw_post_data
53 57
    if body is None:
......
56 60

  
57 61
callpoints = {('quotaholder', 'v'): API_Callpoint()}
58 62

  
63

  
59 64
@transaction.commit_manually
60 65
@csrf_exempt
61 66
def view(request, appname='quotaholder', version=None, callname=None):
......
70 75
    try:
71 76
        body = callpoint.make_call_from_json(callname, body)
72 77
        status = 200
73
    except Exception, e:
78
    except Exception as e:
74 79
        status = 450
75 80
        if not isinstance(e, CallError):
81
            logger.exception(e)
76 82
            e.args += (''.join(format_exc()),)
77 83
            e = CallError.from_exception(e)
78 84
            status = 500

Also available in: Unified diff