z3c.appconfig

Simple application configuration system
Download

z3c.appconfig Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Publisher Name:
  • Wichert Akkerman

z3c.appconfig Tags


z3c.appconfig Description

Simple application configuration system z3c.appconfig is a Python module that provides a method to configure an application via standard .ini files. This is convenient for site admins since they are more likely to be familiar with ini files than with ZCML.Creating config filesThere are two ways to tell a Zope instance which configuration files to load: zcml statements and the APPCONFIG environment variable. zcml statements are processed first, making it possible to override standard configuration.The zcml syntax looks like this:< configure xmlns="http://namespaces.zope.org/zope" > < include package="z3c.appconfig" file="meta.zcml"/ > < appconfig file="default.ini" / >< /configure >This will load the contents of default.ini and merge it into the application configuration.If an APPCONFIG environment variable is set and points to a file its contents will be merged into the application configuration. This is done last, allowing you to override application defined defaults. For example: APPCONFIG=etc/mysite.ini bin/instance fgAccessing configurationThe configuration data can be accessed from your code via a IAppConfig utility. This utility is essentially a standard python dictionary which stores all configuration data. For example lets use a very simple configuration file:title = My lovely siteYou can access the title from python with code like this:from zope.component import getUtilityfrom z3c.appconfig.interfaces import IAppConfigappconfig=getUtility(IAppConfig)print "Site title is: %s" % appconfigUtility methodsAs a convenience a utility method is provided to convert values from a configuration file to booleans: the z3c.appconfig.utils.asBool method:from z3c.appconfig.utils import asBoolprint "Pants are on: %s" % asBool("true") Requirements: · Python What's New in This Release: · Add more trove classifiers. · Add a asBool utility method.


z3c.appconfig Related Software