Mercurial > kallithea
comparison rhodecode/config/environment.py @ 2031:82a88013a3fd
merge 1.3 into stable
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 26 Feb 2012 17:25:09 +0200 |
parents | bf263968da47 6020e3884a58 |
children | dc2584ba5fbc |
comparison
equal
deleted
inserted
replaced
2005:ab0e122b38a7 | 2031:82a88013a3fd |
---|---|
5 | 5 |
6 from mako.lookup import TemplateLookup | 6 from mako.lookup import TemplateLookup |
7 from pylons.configuration import PylonsConfig | 7 from pylons.configuration import PylonsConfig |
8 from pylons.error import handle_mako_error | 8 from pylons.error import handle_mako_error |
9 | 9 |
10 import rhodecode | |
10 import rhodecode.lib.app_globals as app_globals | 11 import rhodecode.lib.app_globals as app_globals |
11 import rhodecode.lib.helpers | 12 import rhodecode.lib.helpers |
12 | 13 |
13 from rhodecode.config.routing import make_map | 14 from rhodecode.config.routing import make_map |
14 from rhodecode.lib import celerypylons | 15 # don't remove this import it does magic for celery |
16 from rhodecode.lib import celerypylons, str2bool | |
15 from rhodecode.lib import engine_from_config | 17 from rhodecode.lib import engine_from_config |
16 from rhodecode.lib.timerproxy import TimerProxy | |
17 from rhodecode.lib.auth import set_available_permissions | 18 from rhodecode.lib.auth import set_available_permissions |
18 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config | 19 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config |
19 from rhodecode.model import init_model | 20 from rhodecode.model import init_model |
20 from rhodecode.model.scm import ScmModel | 21 from rhodecode.model.scm import ScmModel |
21 | 22 |
36 templates=[os.path.join(root, 'templates')]) | 37 templates=[os.path.join(root, 'templates')]) |
37 | 38 |
38 # Initialize config with the basic options | 39 # Initialize config with the basic options |
39 config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) | 40 config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) |
40 | 41 |
42 # store some globals into rhodecode | |
43 rhodecode.CELERY_ON = str2bool(config['app_conf'].get('use_celery')) | |
44 | |
41 config['routes.map'] = make_map(config) | 45 config['routes.map'] = make_map(config) |
42 config['pylons.app_globals'] = app_globals.Globals(config) | 46 config['pylons.app_globals'] = app_globals.Globals(config) |
43 config['pylons.h'] = rhodecode.lib.helpers | 47 config['pylons.h'] = rhodecode.lib.helpers |
44 | 48 rhodecode.CONFIG = config |
45 # Setup cache object as early as possible | 49 # Setup cache object as early as possible |
46 import pylons | 50 import pylons |
47 pylons.cache._push_object(config['pylons.app_globals'].cache) | 51 pylons.cache._push_object(config['pylons.app_globals'].cache) |
48 | 52 |
49 # Create the Mako TemplateLookup, with the default auto-escaping | 53 # Create the Mako TemplateLookup, with the default auto-escaping |
52 error_handler=handle_mako_error, | 56 error_handler=handle_mako_error, |
53 module_directory=os.path.join(app_conf['cache_dir'], 'templates'), | 57 module_directory=os.path.join(app_conf['cache_dir'], 'templates'), |
54 input_encoding='utf-8', default_filters=['escape'], | 58 input_encoding='utf-8', default_filters=['escape'], |
55 imports=['from webhelpers.html import escape']) | 59 imports=['from webhelpers.html import escape']) |
56 | 60 |
57 #sets the c attribute access when don't existing attribute are accessed | 61 # sets the c attribute access when don't existing attribute are accessed |
58 config['pylons.strict_tmpl_context'] = True | 62 config['pylons.strict_tmpl_context'] = True |
59 test = os.path.split(config['__file__'])[-1] == 'test.ini' | 63 test = os.path.split(config['__file__'])[-1] == 'test.ini' |
60 if test: | 64 if test: |
61 from rhodecode.lib.utils import create_test_env, create_test_index | 65 from rhodecode.lib.utils import create_test_env, create_test_index |
62 from rhodecode.tests import TESTS_TMP_PATH | 66 from rhodecode.tests import TESTS_TMP_PATH |
63 create_test_env(TESTS_TMP_PATH, config) | 67 create_test_env(TESTS_TMP_PATH, config) |
64 create_test_index(TESTS_TMP_PATH, config, True) | 68 create_test_index(TESTS_TMP_PATH, config, True) |
65 | 69 |
66 #MULTIPLE DB configs | 70 # MULTIPLE DB configs |
67 # Setup the SQLAlchemy database engine | 71 # Setup the SQLAlchemy database engine |
68 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') | 72 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') |
69 | 73 |
70 init_model(sa_engine_db1) | 74 init_model(sa_engine_db1) |
71 | 75 |
75 config['base_path'] = repos_path | 79 config['base_path'] = repos_path |
76 set_rhodecode_config(config) | 80 set_rhodecode_config(config) |
77 # CONFIGURATION OPTIONS HERE (note: all config options will override | 81 # CONFIGURATION OPTIONS HERE (note: all config options will override |
78 # any Pylons config options) | 82 # any Pylons config options) |
79 | 83 |
84 # store config reference into our module to skip import magic of | |
85 # pylons | |
86 rhodecode.CONFIG.update(config) | |
80 return config | 87 return config |