1 """Pylons environment configuration"""
4 from genshi.template import TemplateLoader
5 from pylons.configuration import PylonsConfig
6 from sqlalchemy import engine_from_config
8 import feed.lib.app_globals as app_globals
9 import feed.lib.helpers
10 from feed.config.routing import make_map
11 from feed.model import init_model
13 def load_environment(global_conf, app_conf):
14 """Configure the Pylons environment via the ``pylons.config``
17 config = PylonsConfig()
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')])
26 # Initialize config with the basic options
27 config.init_app(global_conf, app_conf, package='feed', paths=paths)
29 config['routes.map'] = make_map(config)
30 config['pylons.app_globals'] = app_globals.Globals(config)
31 config['pylons.h'] = feed.lib.helpers
33 # Setup cache object as early as possible
35 pylons.cache._push_object(config['pylons.app_globals'].cache)
38 # Create the Genshi TemplateLoader
39 config['pylons.app_globals'].genshi_loader = TemplateLoader(
40 paths['templates'], auto_reload=True)
42 # Setup the SQLAlchemy database engine
43 engine = engine_from_config(config, 'sqlalchemy.')
46 # CONFIGURATION OPTIONS HERE (note: all config options will override
47 # any Pylons config options)