pylons.configuration – Configuration object and defaults setup¶
Configuration object and defaults setup
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.
class pylons.configuration.PylonsConfig(name='DispatchingConfig')¶
Pylons configuration object
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.template_options
Full dict of template options that any TG compatible plugin
should be able to parse. Comes with basic config needed for
Genshi, Mako, Myghty, and Kid.
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.template_engines
List of template engines to configure. The first one in the
list will be configured as the default template engine. Each
item in the list is a dict indicating how to configure the
template engine with keys:
engine, template_root, template_options, and
alias
pylons.default_charset
Deprecated: Use the response_settings dict instead.
Default character encoding specified to the browser via the
‘charset’ parameter of the HTTP response’s Content-Type header.
pylons.strict_c
Whether or not the c object should throw an attribute error
when access is attempted to an attribute that doesn’t exist.
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 0.9.7: template_engine is no longer required, and can be set
to None to avoid loading the default one.
template_engine
Declare the default template engine to setup. Choices are
kid, genshi, mako (the default), and pylonsmyghty.