Mercurial > kallithea
annotate rhodecode/config/environment.py @ 1235:d85614773113
fixed broken yui script during one of the merges
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 09 Apr 2011 19:12:43 +0200 |
parents | 45fed9a435b7 |
children | bf263968da47 |
rev | line source |
---|---|
0 | 1 """Pylons environment configuration""" |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
2 |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
3 import os |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
4 import logging |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
5 |
0 | 6 from mako.lookup import TemplateLookup |
43 | 7 from pylons.configuration import PylonsConfig |
0 | 8 from pylons.error import handle_mako_error |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
9 from sqlalchemy import engine_from_config |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
10 |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
11 import rhodecode.lib.app_globals as app_globals |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
12 import rhodecode.lib.helpers |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
13 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
14 from rhodecode.config.routing import make_map |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
15 from rhodecode.lib import celerypylons |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
16 from rhodecode.lib.auth import set_available_permissions, set_base_path |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
17 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
18 from rhodecode.model import init_model |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
19 from rhodecode.model.scm import ScmModel |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
760
diff
changeset
|
20 from rhodecode.lib.timerproxy import TimerProxy |
239
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
107
diff
changeset
|
21 |
0 | 22 log = logging.getLogger(__name__) |
23 | |
1209
45fed9a435b7
merges for upcoming release
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
24 |
365
ec7b76d4bda4
Added initial query skipp when seting up the app.
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
25 def load_environment(global_conf, app_conf, initial=False): |
0 | 26 """Configure the Pylons environment via the ``pylons.config`` |
27 object | |
28 """ | |
43 | 29 config = PylonsConfig() |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
30 |
0 | 31 # Pylons paths |
32 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
32
f93b523c0be3
dirty fix for multiple file encodings,
Marcin Kuzminski <marcin@python-blog.com>
parents:
12
diff
changeset
|
33 paths = dict(root=root, |
f93b523c0be3
dirty fix for multiple file encodings,
Marcin Kuzminski <marcin@python-blog.com>
parents:
12
diff
changeset
|
34 controllers=os.path.join(root, 'controllers'), |
f93b523c0be3
dirty fix for multiple file encodings,
Marcin Kuzminski <marcin@python-blog.com>
parents:
12
diff
changeset
|
35 static_files=os.path.join(root, 'public'), |
f93b523c0be3
dirty fix for multiple file encodings,
Marcin Kuzminski <marcin@python-blog.com>
parents:
12
diff
changeset
|
36 templates=[os.path.join(root, 'templates')]) |
0 | 37 |
38 # Initialize config with the basic options | |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
39 config.init_app(global_conf, app_conf, package='rhodecode', paths=paths) |
0 | 40 |
43 | 41 config['routes.map'] = make_map(config) |
42 config['pylons.app_globals'] = app_globals.Globals(config) | |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
43 config['pylons.h'] = rhodecode.lib.helpers |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
44 |
43 | 45 # Setup cache object as early as possible |
46 import pylons | |
47 pylons.cache._push_object(config['pylons.app_globals'].cache) | |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
48 |
0 | 49 # Create the Mako TemplateLookup, with the default auto-escaping |
41
71ffa932799d
Added app basic auth.
Marcin Kuzminski <marcin@python-blog.com>
parents:
32
diff
changeset
|
50 config['pylons.app_globals'].mako_lookup = TemplateLookup( |
32
f93b523c0be3
dirty fix for multiple file encodings,
Marcin Kuzminski <marcin@python-blog.com>
parents:
12
diff
changeset
|
51 directories=paths['templates'], |
f93b523c0be3
dirty fix for multiple file encodings,
Marcin Kuzminski <marcin@python-blog.com>
parents:
12
diff
changeset
|
52 error_handler=handle_mako_error, |
f93b523c0be3
dirty fix for multiple file encodings,
Marcin Kuzminski <marcin@python-blog.com>
parents:
12
diff
changeset
|
53 module_directory=os.path.join(app_conf['cache_dir'], 'templates'), |
41
71ffa932799d
Added app basic auth.
Marcin Kuzminski <marcin@python-blog.com>
parents:
32
diff
changeset
|
54 input_encoding='utf-8', default_filters=['escape'], |
71ffa932799d
Added app basic auth.
Marcin Kuzminski <marcin@python-blog.com>
parents:
32
diff
changeset
|
55 imports=['from webhelpers.html import escape']) |
0 | 56 |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
239
diff
changeset
|
57 #sets the c attribute access when don't existing attribute are accessed |
107
5e2470ebdbc6
Added repo switcher, in base and long term caching for this.
Marcin Kuzminski <marcin@python-works.com>
parents:
49
diff
changeset
|
58 config['pylons.strict_tmpl_context'] = True |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
469
diff
changeset
|
59 test = os.path.split(config['__file__'])[-1] == 'test.ini' |
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
469
diff
changeset
|
60 if test: |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
491
diff
changeset
|
61 from rhodecode.lib.utils import create_test_env, create_test_index |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
62 from rhodecode.tests import TESTS_TMP_PATH |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
63 create_test_env(TESTS_TMP_PATH, config) |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
665
diff
changeset
|
64 create_test_index(TESTS_TMP_PATH, True) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
65 |
43 | 66 #MULTIPLE DB configs |
67 # Setup the SQLAlchemy database engine | |
469
e94f4e54dc03
tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
68 if config['debug'] and not test: |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
43
diff
changeset
|
69 #use query time debugging. |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
43
diff
changeset
|
70 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.', |
1209
45fed9a435b7
merges for upcoming release
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
71 proxy=TimerProxy()) |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
43
diff
changeset
|
72 else: |
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
43
diff
changeset
|
73 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') |
43 | 74 |
49
3ada2f409c1c
Added sqlalchemy support
Marcin Kuzminski <marcin@python-blog.com>
parents:
43
diff
changeset
|
75 init_model(sa_engine_db1) |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
365
diff
changeset
|
76 #init baseui |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
309
diff
changeset
|
77 config['pylons.app_globals'].baseui = make_ui('db') |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
78 |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
79 g = config['pylons.app_globals'] |
760
fb7a3b291e64
Cleaned up scm model codes,Admin/admin permissions controller codes
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
80 repo2db_mapper(ScmModel().repo_scan(g.paths[0][1], g.baseui)) |
239
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
107
diff
changeset
|
81 set_available_permissions(config) |
309
7e4771a0ff43
added base path into config
Marcin Kuzminski <marcin@python-works.com>
parents:
300
diff
changeset
|
82 set_base_path(config) |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
83 set_rhodecode_config(config) |
0 | 84 # CONFIGURATION OPTIONS HERE (note: all config options will override |
85 # any Pylons config options) | |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
86 |
43 | 87 return config |