websauna.utils.config.includer module

Support for INI file inclusion mechanism.

class websauna.utils.config.includer.IncludeAwareConfigParser(filename, *args, **kw)[source]

Bases: paste.deploy.loadwsgi.NicerConfigParser

Include .ini settings file in others.

This is a hack to get quick include support for Pyramid INI settings files. This is a variation of Python ConfigParser which knows about [includes] section. In this section you can tell the config file to include other config files.

To add includes add a section in your INI:

[includes]
include_ini_files =
    resource://websauna/conf/production.ini
    resource://websauna/conf/base.ini

Each included file is referred by URL. Currently support protocols are:

The keys in the current INI file sections are added from includes if the keys do not exist yet. Includes are processed from first to last, first taking precedences.

The include is not recursive. E.g. the includes of include are not processed at the moment.

optionxform

alias of builtins.str

process_includes(fpname)[source]

Process includes section.

Parameters

fpname (str) – Main configuration filename.

read_include(include_file, fpname)[source]

Augment the current config entries from another INI file.

Parameters
  • include_file (str) – File to be include.

  • fpname (str) – Main configuration filename.

resolve(include_file, fpname)[source]

Resolve include_file and return a readable file like object.

Parameters
  • include_file (str) – File to be include.

  • fpname (str) – Main configuration filename.

Return type

TextIO

Returns

Return a readable file-like object for the specified resource.

classmethod retrofit_settings(global_config, section='app:main')[source]

Update settings dictionary given to WSGI application constructor by Paster to have included settings.

Parameters
  • global_config (dict) – global_config dict as given by Paster

  • section (str) – Section to be processed.

Return type

dict

Returns

New instance of settings