source: cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/config/environment.py @ 7483

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/config/environment.py@7483
Revision 7483, 1.5 KB checked in by astephen, 9 years ago (diff)

Included additional config args introduced in pylons 0.9.7 to allow the
global "c" variable to maintain access to global properties and to not
throw AttributeError? exceptions when an attribute is not found. See:
 http://wiki.pylonshq.com/pages/viewpage.action?pageId=11174779

Line 
1"""Pylons environment configuration"""
2import os
3
4from pylons.configuration import PylonsConfig
5from genshi.template import TemplateLoader
6
7import cowsserver.lib.app_globals as app_globals
8import cowsserver.lib.helpers
9from cowsserver.config.routing import make_map
10
11from cows.pylons.config import configCSML
12
13def load_environment(global_conf, app_conf):
14    """Configure the Pylons environment via the ``pylons.config``
15    object
16    """
17    config = PylonsConfig()
18
19    # Pylons paths
20    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21    paths = dict(root=root,
22                 controllers=os.path.join(root, 'controllers'),
23                 static_files=os.path.join(root, 'public'),
24                 templates=[os.path.join(root, 'templates')])
25
26    # Initialize config with the basic options
27    config.init_app(global_conf, app_conf, package='cowsserver', paths=paths)
28    config['pylons.strict_c'] = False
29    config['pylons.c_attach_args'] = True
30
31    config['routes.map'] = make_map(config)
32    config['pylons.app_globals'] = app_globals.Globals(config)
33    config['pylons.h'] = cowsserver.lib.helpers
34
35    import pylons
36    pylons.cache._push_object(config['pylons.app_globals'].cache)
37
38    config['pylons.app_globals'].genshi_loader = TemplateLoader(
39        paths['templates'], auto_reload=True)
40
41    # CONFIGURATION OPTIONS HERE (note: all config options will override
42    # any Pylons config options)
43    config['pylons.strict_tmpl_context'] = False
44    configCSML(config)
45
46    return config
47
Note: See TracBrowser for help on using the repository browser.