Switch to unified view

a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
...
...
35
import webob.multidict
35
import webob.multidict
36
from formencode import Invalid
36
from formencode import Invalid
37
from tg.decorators import before_validate
37
from tg.decorators import before_validate
38
from pylons import response
38
from pylons import response
39
from pylons import tmpl_context as c
39
from pylons import tmpl_context as c
40
from paste.deploy.converters import asbool
40
from paste.httpheaders import CACHE_CONTROL, EXPIRES
41
from paste.httpheaders import CACHE_CONTROL, EXPIRES
41
from webhelpers.html import literal
42
from webhelpers.html import literal
42
from webob import exc
43
from webob import exc
43
from pygments.formatters import HtmlFormatter
44
from pygments.formatters import HtmlFormatter
44
45
...
...
62
        content_type = content_type[0]
63
        content_type = content_type[0]
63
    else:
64
    else:
64
        content_type = 'application/octet-stream'
65
        content_type = 'application/octet-stream'
65
    return content_type
66
    return content_type
66
67
68
67
class ConfigProxy(object):
69
class ConfigProxy(object):
68
    '''Wrapper for loading config values at module-scope so we don't
70
    '''Wrapper for loading config values at module-scope so we don't
69
    have problems when a module is imported before tg.config is initialized
71
    have problems when a module is imported before tg.config is initialized
70
    '''
72
    '''
71
73
72
    def __init__(self, **kw):
74
    def __init__(self, **kw):
73
        self._kw = kw
75
        self._kw = kw
74
76
75
    def __getattr__(self, k):
77
    def __getattr__(self, k):
76
        return tg.config[self._kw[k]]
78
        return self.get(k)
79
80
    def get(self, key, default=None):
81
        return tg.config.get(self._kw.get(key, key), default)
82
83
    def get_bool(self, key):
84
        return asbool(self.get(key))
85
77
86
78
class lazy_logger(object):
87
class lazy_logger(object):
79
    '''Lazy instatiation of a logger, to ensure that it does not get
88
    '''Lazy instatiation of a logger, to ensure that it does not get
80
    created before logging is configured (which would make it disabled)'''
89
    created before logging is configured (which would make it disabled)'''
81
90