comparison pylons_app/config/environment.py @ 0:564e40829f80

initial commit.
author Marcin Kuzminski
date Thu, 18 Feb 2010 13:01:57 +0100
parents
children 5f30a6d558dc
comparison
equal deleted inserted replaced
-1:000000000000 0:564e40829f80
1 """Pylons environment configuration"""
2 import logging
3 import os
4 from pylons import config
5 from mako.lookup import TemplateLookup
6 from pylons.error import handle_mako_error
7 import pylons_app.lib.app_globals as app_globals
8 import pylons_app.lib.helpers
9 from pylons_app.config.routing import make_map
10
11 log = logging.getLogger(__name__)
12
13 def load_environment(global_conf, app_conf):
14 """Configure the Pylons environment via the ``pylons.config``
15 object
16 """
17 # Pylons paths
18 root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19 paths = dict(root = root,
20 controllers = os.path.join(root, 'controllers'),
21 static_files = os.path.join(root, 'public'),
22 templates = [os.path.join(root, 'templates')])
23
24 # Initialize config with the basic options
25 config.init_app(global_conf, app_conf, package = 'pylons_app',
26 template_engine = 'mako', paths = paths)
27
28 config['routes.map'] = make_map()
29 config['pylons.g'] = app_globals.Globals()
30 config['pylons.h'] = pylons_app.lib.helpers
31
32 # Create the Mako TemplateLookup, with the default auto-escaping
33 config['pylons.g'].mako_lookup = TemplateLookup(
34 directories = paths['templates'],
35 error_handler = handle_mako_error,
36 module_directory = os.path.join(app_conf['cache_dir'], 'templates'),
37 input_encoding = 'utf-8', default_filters = ['escape'],
38 imports = ['from webhelpers.html import escape'])
39
40 # Customize templating options via this variable
41 tmpl_options = config['buffet.template_options']
42
43 # CONFIGURATION OPTIONS HERE (note: all config options will override
44 # any Pylons config options)