Revision 784dcbdb
b/snf-common/synnefo/lib/commissioning/exception.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 |
... | ... | |
61 | 61 |
|
62 | 62 |
def __repr__(self): |
63 | 63 |
return '%s(%s)' % (self.__class__.__name__, |
64 |
','.join(str_or_utf8(x) for x in self.args))
|
|
64 |
','.join(repr(x) for x in self.args))
|
|
65 | 65 |
|
66 | 66 |
@classmethod |
67 | 67 |
def from_exception(cls, exc): |
... | ... | |
77 | 77 |
return self |
78 | 78 |
|
79 | 79 |
def to_dict(self): |
80 |
args = tuple(str_or_utf8(x) for x in self.args) |
|
81 |
kwargs = dict((str_or_utf8(k), str_or_utf8(v)) |
|
82 |
for k, v in self.kwargs.iteritems()) |
|
80 | 83 |
return {'call_error': self.call_error, |
81 |
'error_args': (self.args, self.kwargs)}
|
|
84 |
'error_args': (args, kwargs)}
|
|
82 | 85 |
|
83 | 86 |
@classmethod |
84 | 87 |
def from_dict(cls, dictobj): |
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