##// END OF EJS Templates
added logging info about loaded rcext
marcink -
r2107:3ed6b940 beta
parent child Browse files
Show More
@@ -1,93 +1,94
1 1 """Pylons environment configuration"""
2 2
3 3 import os
4 4 import logging
5 5
6 6 from mako.lookup import TemplateLookup
7 7 from pylons.configuration import PylonsConfig
8 8 from pylons.error import handle_mako_error
9 9
10 10 import rhodecode
11 11 import rhodecode.lib.app_globals as app_globals
12 12 import rhodecode.lib.helpers
13 13
14 14 from rhodecode.config.routing import make_map
15 15 # don't remove this import it does magic for celery
16 16 from rhodecode.lib import celerypylons, str2bool
17 17 from rhodecode.lib import engine_from_config
18 18 from rhodecode.lib.auth import set_available_permissions
19 19 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config
20 20 from rhodecode.model import init_model
21 21 from rhodecode.model.scm import ScmModel
22 22 from rhodecode.lib.vcs.utils.fakemod import create_module
23 23
24 24 log = logging.getLogger(__name__)
25 25
26 26
27 27 def load_environment(global_conf, app_conf, initial=False):
28 28 """Configure the Pylons environment via the ``pylons.config``
29 29 object
30 30 """
31 31 config = PylonsConfig()
32 32
33 33 # Pylons paths
34 34 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
35 35 paths = dict(root=root,
36 36 controllers=os.path.join(root, 'controllers'),
37 37 static_files=os.path.join(root, 'public'),
38 38 templates=[os.path.join(root, 'templates')])
39 39
40 40 # Initialize config with the basic options
41 41 config.init_app(global_conf, app_conf, package='rhodecode', paths=paths)
42 42
43 43 # store some globals into rhodecode
44 44 rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
45 45
46 46 config['routes.map'] = make_map(config)
47 47 config['pylons.app_globals'] = app_globals.Globals(config)
48 48 config['pylons.h'] = rhodecode.lib.helpers
49 49 rhodecode.CONFIG = config
50 50
51 51 path = os.path.join(config['here'], 'rcextensions', '__init__.py')
52 52 if os.path.isfile(path):
53 53 rcext = create_module('rc', path)
54 54 rhodecode.EXTENSIONS = rcext
55 log.debug('Found rcextensions now loading %s...' % rcext)
55 56 # Setup cache object as early as possible
56 57 import pylons
57 58 pylons.cache._push_object(config['pylons.app_globals'].cache)
58 59
59 60 # Create the Mako TemplateLookup, with the default auto-escaping
60 61 config['pylons.app_globals'].mako_lookup = TemplateLookup(
61 62 directories=paths['templates'],
62 63 error_handler=handle_mako_error,
63 64 module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
64 65 input_encoding='utf-8', default_filters=['escape'],
65 66 imports=['from webhelpers.html import escape'])
66 67
67 68 # sets the c attribute access when don't existing attribute are accessed
68 69 config['pylons.strict_tmpl_context'] = True
69 70 test = os.path.split(config['__file__'])[-1] == 'test.ini'
70 71 if test:
71 72 from rhodecode.lib.utils import create_test_env, create_test_index
72 73 from rhodecode.tests import TESTS_TMP_PATH
73 74 create_test_env(TESTS_TMP_PATH, config)
74 75 create_test_index(TESTS_TMP_PATH, config, True)
75 76
76 77 # MULTIPLE DB configs
77 78 # Setup the SQLAlchemy database engine
78 79 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
79 80
80 81 init_model(sa_engine_db1)
81 82
82 83 repos_path = make_ui('db').configitems('paths')[0][1]
83 84 repo2db_mapper(ScmModel().repo_scan(repos_path))
84 85 set_available_permissions(config)
85 86 config['base_path'] = repos_path
86 87 set_rhodecode_config(config)
87 88 # CONFIGURATION OPTIONS HERE (note: all config options will override
88 89 # any Pylons config options)
89 90
90 91 # store config reference into our module to skip import magic of
91 92 # pylons
92 93 rhodecode.CONFIG.update(config)
93 94 return config
General Comments 0
You need to be logged in to leave comments. Login now