3470f2a803a4bf424d5ca69a3693c44d929f93c9
1 """Pylons environment configuration"""
4 from mako
.lookup
import TemplateLookup
5 from pylons
import config
6 from sqlalchemy
import engine_from_config
8 import floof
.lib
.app_globals
as app_globals
9 import floof
.lib
.helpers
10 from floof
.config
.routing
import make_map
11 import floof
.model
as model
13 def load_environment(global_conf
, app_conf
):
14 """Configure the Pylons environment via the ``pylons.config``
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')])
24 # Initialize config with the basic options
25 config
.init_app(global_conf
, app_conf
, package
='floof', paths
=paths
)
27 config
['routes.map'] = make_map()
28 config
['pylons.app_globals'] = app_globals
.Globals()
29 config
['pylons.h'] = floof
.lib
.helpers
31 # Create the Mako TemplateLookup, with the default auto-escaping
32 config
['pylons.app_globals'].mako_lookup
= TemplateLookup(
33 directories
=paths
['templates'],
34 module_directory
=os
.path
.join(app_conf
['cache_dir'], 'templates'),
35 input_encoding
='utf-8', output_encoding
='utf-8',
36 imports
=['from webhelpers.html import escape'],
37 default_filters
=['escape'])
39 # Setup the SQLAlchemy^W Elixir database engine
40 engine
= engine_from_config(config
, 'sqlalchemy.')
41 if model
.elixir
.options_defaults
.get('autoload'):
43 model
.elixir
.bind
= engine
44 model
.metadata
.bind
= engine
45 model
.elixir
.setup_all()
47 # Non-reflected tables
48 model
.init_model(engine
)
50 # CONFIGURATION OPTIONS HERE (note: all config options will override
51 # any Pylons config options)