source: cowsclient/trunk/cowsclient/config/environment.py @ 7592

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cowsclient/trunk/cowsclient/config/environment.py@7592
Revision 7592, 1.3 KB checked in by astephen, 10 years ago (diff)

Updated to be compatible with:

  • python 2.6
  • pylons 1.0
Line 
1"""Pylons environment configuration"""
2import os
3
4from genshi.template import TemplateLoader
5from pylons.configuration import PylonsConfig
6
7import cowsclient.lib.app_globals as app_globals
8import cowsclient.lib.helpers
9from cowsclient.config.routing import make_map
10
11def load_environment(global_conf, app_conf):
12    """Configure the Pylons environment via the ``pylons.config``
13    object
14    """
15    config = PylonsConfig()
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='cowsclient', paths=paths)
26
27    config['routes.map'] = make_map(config)
28    config['pylons.app_globals'] = app_globals.Globals(config)
29    config['pylons.h'] = cowsclient.lib.helpers
30
31    config['pylons.app_globals'].genshi_loader = TemplateLoader(
32        paths['templates'], auto_reload=True)
33
34    # CONFIGURATION OPTIONS HERE (note: all config options will override
35    # any Pylons config options)
36    config['pylons.strict_tmpl_context'] = False
37
38    return config
Note: See TracBrowser for help on using the repository browser.