ZConfig.cmdline — Command-line override support

Support for command-line overrides for configuration settings.

This module exports an extended version of the ConfigLoader class from the ZConfig.loader module. This provides support for overriding specific settings from the configuration file from the command line, without requiring the application to provide specific options for everything the configuration file can include.

Each setting is given by a value specifier string, as described by ExtendedConfigLoader.addOption().

class ZConfig.cmdline.ExtendedConfigLoader(schema)

Bases: ZConfig.loader.ConfigLoader

A ConfigLoader subclass that adds support for command-line overrides.

The following additional method is provided, and is the only way to provide position information to associate with command-line parameters:

ExtendedConfigLoader.addOption(spec, pos=None)

Add a single value to the list of overridden values.

The spec argument is a value specifier string of the form optionpath=value. For example:


The optionpath specifies the “full path” to the configuration setting: it can contain a sequence of names, separated by / characters. Each name before the last names a section from the configuration file, and the last name corresponds to a key within the section identified by the leading section names. If optionpath contains only one name, it identifies a key in the top-level schema. value is a string that will be treated just like a value in the configuration file.

A source position for the specifier may be given as pos. If pos is specified and not None, it must be a sequence of three values. The first is the URL of the source (or some other identifying string). The second and third are the line number and column of the setting. These position information is only used to construct a DataConversionError when data conversion fails.