Warning
This documentation does not refer to the most recent version of Pylons. Current Documentation
The Config class is accessible via the pylons.config module.
The Pylons configuration object is a per-application instance object that retains the information regarding the global and app conf's as well as per-application instance specific data such as the mapper, the paths for this instance, and the myghty configuration.
The Config object is available in your application as a Pylons global pylons_config under the g object. There's several useful attributes of the config object most people will be interested in:
Add additional template engines for configuration on Pylons WSGI init
Example of Kid addition:
# In yourproj/middleware.py
# ...
config.init_app(global_conf, app_conf, package='yourproj')
# Load additional template engines
kidopts = {'kid.assume_encoding':'utf-8', 'kid.encoding':'utf-8'}
config.add_template_engine('kid', 'yourproj.kidtemplates', kidopts)
Example of changing the default template engine:
# In yourproj/middleware.py
# ...
config.init_app(global_conf, app_conf, package='yourproj')
# Remove existing template engine
old_default = config.template_engines.pop()
# Load additional template engines
kidopts = {'kid.assume_encoding':'utf-8', 'kid.encoding':'utf-8'}
config.add_template_engine('kid', 'yourproj.kidtemplates', kidopts)
# Add old default as additional engine
config.template_engines.append(old_default)
Initialize configuration for the application
Several options are expected to be set for a Pylons web application. They will be loaded from the global_config which has the main Paste options. If debug is not enabled as a global config option, the following option must be set:
The optional config options in this case are:
See the source for more information.