Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install haufe.hrs.configuration

How to install haufe.hrs.configuration

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install haufe.hrs.configuration
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.5.18 Available View build log
0.5.17 Available View build log
0.5.12.1 Available View build log
Windows (64-bit)
0.5.18 Available View build log
0.5.17 Available View build log
0.5.12.1 Available View build log
Mac OS X (10.5+)
0.5.18 Available View build log
0.5.17 Available View build log
0.5.12.1 Available View build log
Linux (32-bit)
0.5.18 Available View build log
0.5.17 Available View build log
0.5.12.1 Available View build log
Linux (64-bit)
0.5.18 Available View build log
0.5.17 Available View build log
0.5.12.1 Available View build log
 
Author
License
ZPL
Imports
Lastest release
version 0.5.18 on May 23rd, 2012

Introduction

haufe.hrs.configuration provides a central configuration service for Zope-based application with a pseudo-hierarchical configuration mechanism.

Features

  • configurations based on INI files
  • configurations are pseudo-hierarchical (section names can be

System Message: WARNING/2 (<string>, line 13)

Bullet list ends without a blank line; unexpected unindent.

dotted-names (like cms.somepath, foo.bat.something.else)

  • all valid configuration options are defined through a model

System Message: WARNING/2 (<string>, line 16)

Bullet list ends without a blank line; unexpected unindent.

(an INI-style file defining sections, their options, their types and default values). The model is used for performing type-checking and providing defaults

  • models and configuration files can be loaded all-in-one or incremental

System Message: WARNING/2 (<string>, line 20)

Bullet list ends without a blank line; unexpected unindent.

into the configuration service

  • optional supervision of changes to the configuration file (a change

System Message: WARNING/2 (<string>, line 23)

Bullet list ends without a blank line; unexpected unindent.

of a configuration file can trigger an immediate reload of the configuration)

  • very simple API
  • ZCML directives for defining the location of models and configuration files
  • integrates easily with Zope 2 and Zope 3
  • can be used outside Zope (pure Python applications) - the package has only

System Message: WARNING/2 (<string>, line 32)

Bullet list ends without a blank line; unexpected unindent.

a minor number of dependencies to other zope.* packages

  • good test coverage

Defining a model

A model definition may look like this:

[cms]

System Message: ERROR/3 (<string>, line 43)

Inconsistent literal block quoting.

HRSCheckoutPath=string,default=42 HRSCheckoutURL=string HRSImportPath=string HRSImportClientPath=string HRSPreviewPath=string HRSPreviewClientPath=string CvtSGMLtoRtfPath=string CvtSGMLtoRtfMaxWait=int ADB2StartURLbase=string ADB2Version=int ToolboxStartURLbase=string NormenDBStartURLbase=string VADBStartURLbase=string LauflistenStartURL=string HRS2UIStartURLbase=string MedienStartURLbase=string

[cms.db] datenbank1= datenbank2= datenbank3=

You see that the syntax is pretty simple. The syntax is always:

<optionname> = <type>, [default=<default-value>]

<optionname> is mandatory. <type> defaults to 'string' and can be omitted (other types are 'int', 'list', 'float', 'complex' or 'bool'). The '=' is mandatory (otherwise Python's configuration parser will spit out an error. An optional default can be defined (otherwise None will be used). Hint: a string as default value must use quotes.

A related configuration file may look like this:

[cms]

System Message: ERROR/3 (<string>, line 79)

Inconsistent literal block quoting.

HRSCheckout = /foo/bar adb2version = 44 hrscheckoutpath = 12 port = 22

[toolbox] partition_id = Toolbox nginx_baseurl = http://weiss.nix.de/

For values of the configuration are accessible through dotted-names like:

System Message: WARNING/2 (<string>, line 91)

Literal block expected; none found.

cms.ADB2Version cms.HRSCheckoutURL cms.db.datenbank

Usage

From Python:

System Message: WARNING/2 (<string>, line 100)

Literal block expected; none found.

from haufe.hrs.configuration import ConfigurationService

service = ConfigurationService(watch=True) service.registerModel('example/model') service.loadConfiguration('example/sample_config/all-in-one.ini') print service.getConfiguration() print service.get('cms.ADB2Version') print service.get('datenbank', domain='cms.db')

ZCML integration

haufe.hrs.configuration provides two ZCML directives haufe:registerModel and haufe:registerConfiguration:

<configure xmlns="http://namespaces.zope.org/zope"

System Message: ERROR/3 (<string>, line 117)

Inconsistent literal block quoting.

xmlns:haufe="http://namespaces.haufe.de/haufe">

<haufe:registerModel model="haufe/hrs/configuration/tests/model" />

<haufe:registerConfiguration configuration="haufe/hrs/configuration/tests/example-config.ini" />

</configure>

The path names for model and configuration can be absolute paths, paths relative to the location of the current ZCML file or a path string containing environment variables (will be substituted automatically).

Credits

The implementation is based on the cfgparse module by Dann Gass

Author

haufe.hrs.configuration was written by Andreas Jung for Haufe Mediengruppe, Freiburg, Germany and ZOPYX Ltd. & Co. KG, Tuebingen, Germany.

License

haufe.hrs.configuration is licensed under the Zope Public License 2.1. See the included ZPL.txt file.

Contact
ZOPYX Ltd. & Co. KG
Andreas Jung
Charlottenstr. 37/1
D-72070 Tuebingen, Germany
E-mail: info at zopyx dot com

Changelog

0.5.18 (2012-05-16)
  • added configure zcml for registering haufe.hrs.configuration.services.CentralConfigurationService utility to centralize loading it via buildout zcml directive
0.5.17 (2011-05-23)
  • fixed improper fix made in 0.5.16
  • fixed reST structure
0.5.16 (2011-05-23)
  • made path to test model and test config absolute for testrunner as long as haufe.hrs.configuration

System Message: WARNING/2 (<string>, line 176)

Bullet list ends without a blank line; unexpected unindent.

is not able to distinguish if it runs in test mode from egg or production mode from instance dir

0.5.15 (2011-03-03)
  • added another missing path to test config
0.5.14 (2011-03-03)
  • corrected path to test configurations
0.5.13 (2011-03-02)
  • made util failsafe if opts are empty
  • corrected tests to run in eggified environtment
  • typo correction
0.5.12 (2009-10-15)
  • fixed typos in documentation
  • removed stupid restriction that model files must end with .ini
0.5.11 (2009-07-07)
  • preserving case of keys and do not map them blindly to lower-case
0.5.10 (2009-05-14)
  • removed hard-coded dependency on pyinotify
0.5.9 (2009-03-17)
  • using lists insteads of sets for keeping the

System Message: WARNING/2 (<string>, line 213)

Bullet list ends without a blank line; unexpected unindent.

list of configuration and model filenames

0.5.8 (2009-03-03)
  • made logging less verbose
  • some more tests
0.5.7 (2009-02-23)
  • using OptionNotSetMarker
0.5.6 (2009-01-13)
  • extended cfgparse module with 'bool' type support
0.5.5 (2009-01-13)
  • registerModel() now triggers a reload() in order

System Message: WARNING/2 (<string>, line 237)

Bullet list ends without a blank line; unexpected unindent.

to provide configuration support for configuration options with a default

0.5.4 (2008-11-21)
  • refactored services
0.5.3 (2008-11-21)
  • removed service_hrs.py since it moved into the HaufeCMS core
0.5.2 (2008-11-17)
  • refactored notification thread handling
0.5.1 (2008-11-12)
  • pre-set some instance vars within the service constructor
0.5.0 (2008-11-12)
  • configurations without a default value will raise a KeyError

System Message: WARNING/2 (<string>, line 266)

Bullet list ends without a blank line; unexpected unindent.

in case no configuration value is available - service.get() raises now a KeyError instead of a ValueError in case of a lookup failure - renamed 'prefix' to 'domain' - cleaned-up ZCML configuration (names and namespace). Check with README.txt

0.4.5 (2008-11-11)
  • configuration paths in ZCML configurations can now be relative

System Message: WARNING/2 (<string>, line 278)

Bullet list ends without a blank line; unexpected unindent.

to the location of the related ZCML file - minor cleanup

0.4.4 (2008-11-07)
  • don't modify the logger level when running in a Zope environment
  • the notifications should now work more reliably. The reload()

System Message: WARNING/2 (<string>, line 286)

Bullet list ends without a blank line; unexpected unindent.

method is triggered after a delay of five seconds in order to handle slow editors

0.4.3 (2008-11-06)
  • added explicit shutdown() function (required for proper Z2 integration)
0.4.2 (internal release)
  • added service.getConfigurationFor()
0.4.1 (2008-11-03)
  • removed haufe.decorator dependency
0.4.0 (2008-11-03)
  • first public release
  • updated documentation and tests
  • some internal cleanup in order to fix race-conditions
0.3.0 (2008-11-02)
  • added pyinotify dependency
  • watching configuration file changes
  • sending ConfigurationChangedEvent upon reload()
0.2.0 (2008-11-01)
  • added service implementation
  • added zcml implementation
  • more tests
0.1.0 (2008-10-31)
  • Initial release

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.