Mercurial > kallithea
comparison pylons_app/config/environment.py @ 252:3782a6d698af
licensing updates, code cleanups
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 04 Jun 2010 13:08:29 +0200 |
parents | b18f89d6d17f |
children | 0e5455fda8fd |
comparison
equal
deleted
inserted
replaced
251:127dba22e53b | 252:3782a6d698af |
---|---|
2 from mako.lookup import TemplateLookup | 2 from mako.lookup import TemplateLookup |
3 from pylons.configuration import PylonsConfig | 3 from pylons.configuration import PylonsConfig |
4 from pylons.error import handle_mako_error | 4 from pylons.error import handle_mako_error |
5 from pylons_app.config.routing import make_map | 5 from pylons_app.config.routing import make_map |
6 from pylons_app.lib.auth import set_available_permissions | 6 from pylons_app.lib.auth import set_available_permissions |
7 from pylons_app.lib.utils import repo2db_mapper | |
7 from pylons_app.model import init_model | 8 from pylons_app.model import init_model |
8 from sqlalchemy import engine_from_config | 9 from sqlalchemy import engine_from_config |
9 import logging | 10 import logging |
10 import os | 11 import os |
11 import pylons_app.lib.app_globals as app_globals | 12 import pylons_app.lib.app_globals as app_globals |
12 import pylons_app.lib.helpers | 13 import pylons_app.lib.helpers |
13 | |
14 | |
15 | 14 |
16 log = logging.getLogger(__name__) | 15 log = logging.getLogger(__name__) |
17 | 16 |
18 def load_environment(global_conf, app_conf): | 17 def load_environment(global_conf, app_conf): |
19 """Configure the Pylons environment via the ``pylons.config`` | 18 """Configure the Pylons environment via the ``pylons.config`` |
37 | 36 |
38 # Setup cache object as early as possible | 37 # Setup cache object as early as possible |
39 import pylons | 38 import pylons |
40 pylons.cache._push_object(config['pylons.app_globals'].cache) | 39 pylons.cache._push_object(config['pylons.app_globals'].cache) |
41 | 40 |
42 | |
43 # Create the Mako TemplateLookup, with the default auto-escaping | 41 # Create the Mako TemplateLookup, with the default auto-escaping |
44 config['pylons.app_globals'].mako_lookup = TemplateLookup( | 42 config['pylons.app_globals'].mako_lookup = TemplateLookup( |
45 directories=paths['templates'], | 43 directories=paths['templates'], |
46 error_handler=handle_mako_error, | 44 error_handler=handle_mako_error, |
47 module_directory=os.path.join(app_conf['cache_dir'], 'templates'), | 45 module_directory=os.path.join(app_conf['cache_dir'], 'templates'), |
48 input_encoding='utf-8', default_filters=['escape'], | 46 input_encoding='utf-8', default_filters=['escape'], |
49 imports=['from webhelpers.html import escape']) | 47 imports=['from webhelpers.html import escape']) |
50 | 48 |
51 #sets the c attribute access when don't existing attribute ar accessed | 49 #sets the c attribute access when don't existing attribute are accessed |
52 config['pylons.strict_tmpl_context'] = True | 50 config['pylons.strict_tmpl_context'] = True |
53 | 51 |
54 #MULTIPLE DB configs | 52 #MULTIPLE DB configs |
55 # Setup the SQLAlchemy database engine | 53 # Setup the SQLAlchemy database engine |
56 if config['debug']: | 54 if config['debug']: |
60 proxy=TimerProxy()) | 58 proxy=TimerProxy()) |
61 else: | 59 else: |
62 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') | 60 sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.') |
63 | 61 |
64 init_model(sa_engine_db1) | 62 init_model(sa_engine_db1) |
65 | 63 repo2db_mapper() |
66 set_available_permissions(config) | 64 set_available_permissions(config) |
67 # CONFIGURATION OPTIONS HERE (note: all config options will override | 65 # CONFIGURATION OPTIONS HERE (note: all config options will override |
68 # any Pylons config options) | 66 # any Pylons config options) |
69 | 67 |
70 return config | 68 return config |