Revision 9fb7a900 snf-astakos-app/astakos/im/views/util.py

b/snf-astakos-app/astakos/im/views/util.py
1
# Copyright 2011-2012 GRNET S.A. All rights reserved.
1
# Copyright 2011, 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
......
49 49
from astakos.im import presentation
50 50
from astakos.im.util import model_to_dict
51 51
from astakos.im.models import Resource
52
import astakos.im.messages as astakos_messages
53
import logging
54

  
55
logger = logging.getLogger(__name__)
56

  
57

  
58
class ExceptionHandler(object):
59
    def __init__(self, request):
60
        self.request = request
61

  
62
    def __enter__(self):
63
        pass
64

  
65
    def __exit__(self, exc_type, value, traceback):
66
        if value is not None:  # exception
67
            logger.exception(value)
68
            m = _(astakos_messages.GENERIC_ERROR)
69
            messages.error(self.request, m)
70
            return True  # suppress exception
71

  
52 72

  
53 73
def render_response(template, tab=None, status=200, context_instance=None, **kwargs):
54 74
    """

Also available in: Unified diff