Bring order to the chaos of configuration using a hierarchy of cofiguration files and your environment
Python Shell
Switch branches/tags
Nothing to show
Clone or download


Build Status Coverage Status Code Climate Documentation Status PyPI Wheels Downloads License

As your application grows, configuration can get a bit chaotic, especially if you have multiple versions (local, deployed, staging, etc.) Ordbok brings order to that chaos.

Ordbok abstracts the loading of a configuration from YAML files into a Python dictionary, and also has a specific setup for use with Flask. See TODO for plans to expand this.

Svenska Akademiens ordbok Svenska Akademiens ordbok by droemmaskin on deviantART. Provided under Attribution-NonCommercial-ShareAlike 3.0 Unported


Full Docs hosted by Read the Docs.

Basic Usage

Ordbok is designed to allow users to define a hierarchy of YAML configuration files and specify environments. The default configuration has three tiers: config.yml, local_config.yml, and Environmental Variables. The later tiers override the earlier ones, and earlier configurations can explicitly require certain variables to be defined in a later one. This can be particularly useful when you expect, say, certain variables to be specified in the environment on a production server and want to fail hard and explicitly when that variable isn't present.

Private Configuration

Ordbok also has the ability to handle an encrypted config file, which can simplify the process of storing and maintaining secret API keys for your application. A config file can be encrypted with Ordbok's CLI:

ordbok encrypt <path_to_file> <password>

In your production environment (or anywhere else you wish to use the private files), simply set PRIVATE_KEY_ORDBOK in the environment (or you can set the value under that key in your Ordbok instance in your application logic) to decrypt the file in that environment. Of course, this key still needs to be handled with care, but this does simplify the process of updating keys and retaining them in your repository without risk of exposing them.

This is not setup with the default configuration, but you can see the docs on File Types for more details.


Inside a virtualenv run

pip install ordbok


from ordbok import Ordbok
config = Ordbok()

Then, in your app root path, create a directory config and add two files config.yml and local_config.yml. See the examples for an example YAML configuration.