app_globals.py
33 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
Marcin Kuzminski
|
r0 | """The application's Globals object""" | ||
r113 | ||||
r43 | from beaker.cache import CacheManager | |||
from beaker.util import parse_cache_config_options | ||||
r341 | from vcs.utils.lazy import LazyProperty | |||
r43 | ||||
Marcin Kuzminski
|
r0 | class Globals(object): | ||
"""Globals acts as a container for objects available throughout the | ||||
life of the application | ||||
""" | ||||
r43 | def __init__(self, config): | |||
Marcin Kuzminski
|
r0 | """One instance of Globals is created during application | ||
initialization and is available during requests via the | ||||
'app_globals' variable | ||||
""" | ||||
r43 | self.cache = CacheManager(**parse_cache_config_options(config)) | |||
r165 | self.changeset_annotation_colors = {} | |||
r341 | self.available_permissions = None # propagated after init_model | |||
self.app_title = None # propagated after init_model | ||||
self.baseui = None # propagated after init_model | ||||
@LazyProperty | ||||
def paths(self): | ||||
if self.baseui: | ||||
return self.baseui.configitems('paths') | ||||
@LazyProperty | ||||
def base_path(self): | ||||
if self.baseui: | ||||
return self.paths[0][1].replace('*', '') | ||||