All Services applications need to use the same configuration file format. This document specifies it.
The configuration file is a ini-based file. (See http://en.wikipedia.org/wiki/INI_file for more details.) Variable names can be assigned values, and grouped into sections.
A line that starts with “#” is commented out. Empty lines are also removed.
Example:
[section1]
# comment
name = value
name2 = "other value"
[section2]
foo = bar
Ini readers in Python, PHP and other languages understand this syntax. Although, there are subtle differences in the way they interpret values and in particular if/how they convert them.
Here are a set of rules for converting values:
Examples:
[section1]
# comment
a_flag = True
a_number = 1
a_string = "other=value"
another_string = other value
a_list = one
two
three
user = ${USERNAME}
An INI file can extend another file. For this, a “DEFAULT” section must contain an “extends” variable that can point to one or several INI files which will be merged into the current file by adding new sections and values.
If the file pointed to in “extends” contains section/variable names that already exist in the original file, they will not override existing ones.
file_one.ini:
[section1]
name2 = "other value"
[section2]
foo = baz
bas = bar
file_two.ini:
[DEFAULT]
extends = file_one.ini
[section2]
foo = bar
Result:
[section1]
name2 = "other value"
[section2]
foo = bar
bas = bar
To point to several files, the multi-line notation can be used:
[DEFAULT]
extends = file_one.ini
file_two.ini
When several files are provided, they are processed sequentially. So if the first one has a value that is also present in the second, the second one will be ignored. This means that the configuration goes from the most specialized to the most common.
There’s one implementation in the core package of the Python server, but it could be moved to a standalone distribution if another project wants to use it.
http://bitbucket.org/tarek/sync-core/src/tip/services/config.py