comparison rhodecode/config/environment.py @ 2165:dc2584ba5fbc

merged beta into default branch
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 28 Mar 2012 19:54:16 +0200
parents 82a88013a3fd 8ecfed1d8f8b
children edfff9f37916
comparison
equal deleted inserted replaced
2097:8fd6650bb436 2165:dc2584ba5fbc
1 """Pylons environment configuration""" 1 """Pylons environment configuration"""
2 2
3 import os 3 import os
4 import logging 4 import logging
5 import rhodecode
5 6
6 from mako.lookup import TemplateLookup 7 from mako.lookup import TemplateLookup
7 from pylons.configuration import PylonsConfig 8 from pylons.configuration import PylonsConfig
8 from pylons.error import handle_mako_error 9 from pylons.error import handle_mako_error
9 10
10 import rhodecode 11 # don't remove this import it does magic for celery
12 from rhodecode.lib import celerypylons
13
11 import rhodecode.lib.app_globals as app_globals 14 import rhodecode.lib.app_globals as app_globals
12 import rhodecode.lib.helpers
13 15
14 from rhodecode.config.routing import make_map 16 from rhodecode.config.routing import make_map
15 # don't remove this import it does magic for celery 17
16 from rhodecode.lib import celerypylons, str2bool 18 from rhodecode.lib import helpers
17 from rhodecode.lib import engine_from_config
18 from rhodecode.lib.auth import set_available_permissions 19 from rhodecode.lib.auth import set_available_permissions
19 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config 20 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config,\
21 load_rcextensions
22 from rhodecode.lib.utils2 import engine_from_config, str2bool
20 from rhodecode.model import init_model 23 from rhodecode.model import init_model
21 from rhodecode.model.scm import ScmModel 24 from rhodecode.model.scm import ScmModel
22 25
23 log = logging.getLogger(__name__) 26 log = logging.getLogger(__name__)
24 27
25 28
26 def load_environment(global_conf, app_conf, initial=False): 29 def load_environment(global_conf, app_conf, initial=False):
27 """Configure the Pylons environment via the ``pylons.config`` 30 """
31 Configure the Pylons environment via the ``pylons.config``
28 object 32 object
29 """ 33 """
30 config = PylonsConfig() 34 config = PylonsConfig()
31 35
32 # Pylons paths 36 # Pylons paths
33 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 37 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
34 paths = dict(root=root, 38 paths = dict(
35 controllers=os.path.join(root, 'controllers'), 39 root=root,
36 static_files=os.path.join(root, 'public'), 40 controllers=os.path.join(root, 'controllers'),
37 templates=[os.path.join(root, 'templates')]) 41 static_files=os.path.join(root, 'public'),
42 templates=[os.path.join(root, 'templates')]
43 )
38 44
39 # Initialize config with the basic options 45 # Initialize config with the basic options
40 config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) 46 config.init_app(global_conf, app_conf, package='rhodecode', paths=paths)
41 47
42 # store some globals into rhodecode 48 # store some globals into rhodecode
43 rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery')) 49 rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
44 50
45 config['routes.map'] = make_map(config) 51 config['routes.map'] = make_map(config)
46 config['pylons.app_globals'] = app_globals.Globals(config) 52 config['pylons.app_globals'] = app_globals.Globals(config)
47 config['pylons.h'] = rhodecode.lib.helpers 53 config['pylons.h'] = helpers
48 rhodecode.CONFIG = config 54 rhodecode.CONFIG = config
55
56 load_rcextensions(root_path=config['here'])
57
49 # Setup cache object as early as possible 58 # Setup cache object as early as possible
50 import pylons 59 import pylons
51 pylons.cache._push_object(config['pylons.app_globals'].cache) 60 pylons.cache._push_object(config['pylons.app_globals'].cache)
52 61
53 # Create the Mako TemplateLookup, with the default auto-escaping 62 # Create the Mako TemplateLookup, with the default auto-escaping