Structured Configuration Library
ZConfig is a configuration library intended for general use. It supports a hierarchical schema-driven configuration model that allows a schema to specify data conversion routines written in Python. ZConfig’s model is very different from the model supported by the ConfigParser module found in Python’s standard library, and is more suitable to configuration-intensive applications.
ZConfig schema are written in an XML-based language and are able to “import” schema components provided by Python packages. Since components are able to bind to conversion functions provided by Python code in the package (or elsewhere), configuration objects can be arbitrarily complex, with values that have been verified against arbitrary constraints. This makes it easy for applications to separate configuration support from configuration loading even with configuration data being defined and consumed by a wide range of separate packages.
ZConfig is licensed under the Zope Public License, version 2.1. See the file LICENSE.txt in the distribution for the full license text.
Reference documentation is available at https://zconfig.readthedocs.io.
Information on the latest released version of the ZConfig package is available at
You may either create an RPM and install this, or install directly from the source distribution.
There is a mailing list for discussions and questions about ZConfig; more information on the list is available at
One common use of ZConfig is to configure the Python logging framework. This is extremely simple to do as the following example demonstrates:
>>> from ZConfig import configureLoggers >>> configureLoggers(''' ... <logger> ... level INFO ... <logfile> ... PATH STDOUT ... format %(levelname)s %(name)s %(message)s ... </logfile> ... </logger> ... ''')
The above configures the root logger to output messages logged at INFO or above to the console, as we can see in the following example:
>>> from logging import getLogger >>> logger = getLogger() >>> logger.info('An info message') INFO root An info message >>> logger.debug('A debug message')
A more common configuration would see STDOUT replaced with a path to the file into which log entries would be written.
For more information, see the the documentation.
Installing from the source distribution
For a simple installation:
python setup.py install
To install to a user’s home-dir:
python setup.py install --home=<dir>
To install to another prefix (for example, /usr/local):
python setup.py install --prefix=/usr/local
If you need to force the python interpreter to (for example) python2:
python2 setup.py install
For more information on installing packages, please refer to the Python Packaging User Guide.
Change History for ZConfig
- Drop support for Python 2.6 and 3.2 and add support for Python 3.6.
- Run tests with pypy and pypy3 as well.
- Host docs at https://zconfig.readthedocs.io
- BaseLoader is now an abstract class that cannot be instantiated.
- Allow nan, inf and -inf values for floats in configurations. See https://github.com/zopefoundation/ZConfig/issues/16.
- Scripts zconfig (for schema validation) and zconfig_schema2html are ported to Python 3.
- A new ZConfig.sphinx Sphinx extension facilitates automatically documenting ZConfig components using their description and examples in Sphinx documentation. See https://github.com/zopefoundation/ZConfig/pull/25.
- Simplify internal schema processing of max and min occurrence values. See https://github.com/zopefoundation/ZConfig/issues/15.
- Almost all uses of type as a parameter name have been replaced with type_ to avoid shadowing a builtin. These were typically not public APIs and weren’t expected to be called with keyword arguments so there should not be any user-visible changes. See https://github.com/zopefoundation/ZConfig/issues/17
- Add ability to do variable substitution from environment variables using $() syntax.
- Added Python 3.4 support.
- Added Python 3.2 support.
- Fixed ResourceWarning in BaseLoader.openResource().
- Removed an accidentally left pdb statement from the code.
- Fix a bug in Python 3 with the custom string repr() function.
- Added Python 3.3 support.
- Dropped Python 2.4 and 2.5 support.
- Fixed: port values of 0 weren’t allowed. Port 0 is used to request an ephemeral port.
- Adjust test classes to avoid base classes being considered separate test cases by (at least) the “nose” test runner.
- Make FileHandler.reopen thread safe.
- Allow identical redefinition of %define names.
- Added support for IPv6 addresses.
- Fix relative path recognition. https://bugs.launchpad.net/zconfig/+bug/405687
- Added SMTP authentication support for email logger on Python 2.6.
- Improved documentation
- Fixed tests failures on windows.
- Added a convenience function, ZConfig.configureLoggers(text) for configuring loggers.
- Relaxed the requirement for a logger name in logger sections, allowing the logger section to be used for both root and non-root loggers.
- Fixed support for schema descriptions that override descriptions from a base schema. If multiple base schema provide descriptions but the derived schema does not, the first base mentioned that provides a description wins. https://bugs.launchpad.net/zconfig/+bug/259475
- Fixed compatibility bug with Python 2.5.0.
- No longer trigger deprecation warnings under Python 2.6.
- Added support for file rotation by time by specifying when and interval, rather than max-size, for log files.
- Removed dependency on setuptools from the setup.py.
- Made it possible to run unit tests via ‘python setup.py test’ (requires setuptools on sys.path).
- Added better error messages to test failure assertions.
A note on the version number:
Information discovered in the revision control system suggests that some past revision has been called “2.4”, though it is not clear that any actual release was made with that version number. We’re going to skip revision 2.4 entirely to avoid potential issues with anyone using something claiming to be ZConfig 2.4, and go straight to version 2.5.
- Add support for importing schema components from ZIP archives (including eggs).
- Added a ‘formatter’ configuration option in the logging handler sections to allow specifying a constructor for the formatter.
- Documented the package: URL scheme that can be used in extending schema.
- Added support for reopening all log files opened via configurations using the ZConfig.components.logger package. For Zope, this is usable via the zc.signalhandler package. zc.signalhandler is not required for ZConfig.
- Added support for rotating log files internally by size.
- Added a minimal implementation of schema-less parsing; this is mostly intended for applications that want to read several fragments of ZConfig configuration files and assemble a combined configuration. Used in some zc.buildout recipes.
- Converted to using zc.buildout and the standard test runner from zope.testing.
- Added more tests.
- Isolated some of the case-normalization code so it will at least be easier to override. This remains non-trivial.
- Added “inet-binding-address” and “inet-connection-address” to the set of standard datatypes. These are similar to the “inet-address” type, but the default hostname is more sensible. The datatype used should reflect how the value will be used.
- Alternate rotating logfile handler for Windows, to avoid platform limitations on renaming open files. Contributed by Sidnei da Silva.
- For <section> and <multisection>, if the name attribute is omitted, assume name=”*”, since this is what is used most often.
- More documentation has been written.
- Added a timedelta datatype function; the input is the same as for the time-interval datatype, but the resulting value is a datetime.timedelta object.
- Make sure keys specified as attributes of the <default> element are converted by the appropriate key type, and are re-checked for derived sections.
- Refactored the ZConfig.components.logger schema components so that a schema can import just one of the “eventlog” or “logger” sections if desired. This can be helpful to avoid naming conflicts.
- Added a reopen() method to the logger factories.
- Always use an absolute pathname when opening a FileHandler.
- A fix to the logger ‘format’ key to allow the %(process)d expansion variable that the logging package supports.
- A new timedelta built-in datatype was added. Similar to time-interval except that it returns a datetime.timedelta object instead.
- Removed compatibility with Python 2.1 and 2.2.
- Schema components must really be in Python packages; the directory search has been modified to perform an import to locate the package rather than incorrectly implementing the search algorithm.
- The default objects use for section values now provide a method getSectionAttributes(); this returns a list of all the attributes of the section object which store configuration-defined data (including information derived from the schema).
- Default information can now be included in a schema for <key name=”+”> and <multikey name=”+”> by using <default key=”…”>.
- More documentation has been added to discuss schema extension.
- Support for a Unicode-free Python has been fixed.
- Derived section types now inherit the datatype of the base type if no datatype is identified explicitly.
- Derived section types can now override the keytype instead of always inheriting from their base type.
- <import package=’…’/> makes use of the current prefix if the package name begins witha dot.
- Added two standard datatypes: dotted-name and dotted-suffix.
- Added two standard schema components: ZConfig.components.basic and ZConfig.components.logger.
- Configurations can import additional schema components using a new “%import” directive; this can be used to integrate 3rd-party components into an application.
- Schemas may be extended using a new “extends” attribute on the <schema> element.
- Better error messages when elements in a schema definition are improperly nested.
- The “zconfig” script can now simply verify that a schema definition is valid, if that’s all that’s needed.
- Initial release.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, Size & Hash SHA256 Hash Help||File Type||Python Version||Upload Date|
(123.6 kB) Copy SHA256 Hash SHA256
|Wheel||py2.py3||Jun 23, 2017|
(115.2 kB) Copy SHA256 Hash SHA256
|Source||None||Jun 23, 2017|