The PylonsConfig object is initialized in pylons projects inside the
config/environment.py module. Importing the config
object from module causes the PylonsConfig object to be created, and
setup in app-safe manner so that multiple apps being setup avoid
conflicts.
After importing config, the project should then call
init_app() with the appropriate options to setup
the configuration. In the config data passed with
init_app(), various defaults are set use with Paste
and Routes.
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, and the paths for this instance.
The config object is available in your application as the Pylons
global pylons.config. For example:
There’s several useful keys of the config object most people will
be interested in:
pylons.paths
A dict of absolute paths that were defined in the applications
config/environment.py module.
pylons.environ_config
Dict of environ keys for where in the environ to pickup various
objects for registering with Pylons. If these are present then
PylonsApp will use them from environ rather than using default
middleware from Beaker. Valid keys are: session,cache
pylons.strict_tmpl_context
Whether or not the tmpl_context object should throw an
attribute error when access is attempted to an attribute that
doesn’t exist. Defaults to True.
pylons.tmpl_context_attach_args
Whethor or not Routes variables should automatically be
attached to the tmpl_context object when specified in a
controllers method.
pylons.request_options
A dict of Content-Type related default settings for new
instances of Request. May
contain the values charset and errors and
decode_param_names. Overrides the Pylons default values
specified by the request_defaults dict.
pylons.response_options
A dict of Content-Type related default settings for new
instances of Response. May
contain the values content_type, charset and
errors. Overrides the Pylons default values specified by
the response_defaults dict.
routes.map
Mapper object used for Routing. Yes, it is possible to add
routes after your application has started running.
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:
error_to - The email address to send the debug error to
The optional config options in this case are:
smtp_server - The SMTP server to use, defaults to
‘localhost’
error_log - A logfile to write the error to
error_subject_prefix - The prefix of the error email
subject
from_address - Whom the error email should be from
app_conf
Defaults supplied via the [app:main] section from the Paste
config file. load_config only cares about whether a
‘prefix’ option is set, if so it will update Routes to
ensure URL’s take that into account.
package
The name of the application package, to be stored in the
app_conf.
Changed in version 1.0: template_engine option is no longer supported.