Switch to unified view

a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
...
...
4
4
5
import tg
5
import tg
6
from pylons import response
6
from pylons import response
7
from paste.httpheaders import CACHE_CONTROL, EXPIRES
7
from paste.httpheaders import CACHE_CONTROL, EXPIRES
8
from ming.utils import LazyProperty
8
from ming.utils import LazyProperty
9
10
class exceptionless(object):
11
    '''Decorator making the decorated function return 'error_result' on any
12
    exceptions rather than propagating exceptions up the stack
13
    '''
14
15
    def __init__(self, error_result, log=None):
16
        self.error_result = error_result
17
        self.log = log
18
19
    def __call__(self, fun):
20
        fname = 'exceptionless(%s)' % fun.__name__
21
        def inner(*args, **kwargs):
22
            try:
23
                return fun(*args, **kwargs)
24
            except:
25
                if self.log:
26
                    self.log.exception('Error calling %s', fname)
27
                return self.error_result
28
        inner.__name__ = fname
29
        return inner
9
30
10
def cache_forever():
31
def cache_forever():
11
    headers = [
32
    headers = [
12
        (k,v) for k,v in response.headers.items()
33
        (k,v) for k,v in response.headers.items()
13
        if k.lower() not in ('pragma', 'cache-control') ]
34
        if k.lower() not in ('pragma', 'cache-control') ]