view pylons_app/lib/app_globals.py @ 368:e9a6783f5502

fixed user permissions bug when adding permissions to user who couldn load those because of auth decorators Small fix for hg model and injecting dbrepo into cached repos
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 27 Jul 2010 14:54:41 +0200
parents 1ef52a70f3b7
children 0d4fceb91c9c
line wrap: on
line source

"""The application's Globals object"""

from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options
from vcs.utils.lazy import LazyProperty

class Globals(object):
    """Globals acts as a container for objects available throughout the
    life of the application

    """

    def __init__(self, config):
        """One instance of Globals is created during application
        initialization and is available during requests via the
        'app_globals' variable

        """
        self.cache = CacheManager(**parse_cache_config_options(config))
        self.changeset_annotation_colors = {}
        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('*', '')