tiramisu/doc/consistency.txt

87 lines
2.9 KiB
Text
Raw Normal View History

.. default-role:: literal
The global consistency
========================================
2012-10-05 16:00:07 +02:00
Identical option names
----------------------
2012-11-20 17:14:58 +01:00
If an `option.Option()` happens to be defined twice in the
`glossary#schema` (e.g. the `option.OptionDescription()`),
2012-10-05 16:00:07 +02:00
that is the two options actually have the same name, an exception is raised.
The calculation is currently carried out in the samespace, for example
if `config.gc.name` is defined, another option in `gc` with the name
`name` is **not** allowed, whereas `config.whateverelse.name` is still
allowed.
Option's values type validation
--------------------------------
2012-10-05 16:00:07 +02:00
When a value is set to the option, the value is validated by the
2012-11-20 17:14:58 +01:00
option's `option.Option()` validator's type.
2012-10-05 16:00:07 +02:00
Notice that if the option is `multi`, that is the `multi` attribute is set to
`True`, then the validation of the option value accepts a list of values
of the same type.
Requirements
------------
2012-10-05 16:00:07 +02:00
Configuration options can specify requirements as parameters at the init
time, the specification of some links between options or groups allows
to carry out a dependencies calculation. For example, an option can ben
hidden if another option has been set with some expected value. This is
just an example, because the possibilities are hudge.
2012-10-05 16:00:07 +02:00
A requirement is specified using a list of triplets. The first element
of the triplet gives the path of the option that is required, the second
element is the value wich is expected to trigger the callback, and the
third one is the callback's action name (`hide`, `show`...)::
2012-10-05 16:00:07 +02:00
stroption = StrOption('str', 'Test string option', default="abc",
requires=[('int', 1, 'hide')])
2012-10-05 16:00:07 +02:00
Take a look at an example here
2012-11-20 17:14:58 +01:00
`test_option_consistency.test_hidden_if_in()`
Config updates
---------------
2012-10-05 16:00:07 +02:00
New configuration options and groups can be dynamically added.
2012-10-05 16:00:07 +02:00
The configuration has to be *updated* after that the description has been
passed to the Config objet, see:
::
>>> config = Config(descr)
>>> newoption = BoolOption('newoption', 'dummy twoo', default=False)
>>> descr.add_child(newoption)
>>> config.update()
>>> config.newoption
False
2012-10-05 16:00:07 +02:00
in
2012-11-20 17:14:58 +01:00
- `test_option_consistency.test_newoption_add_in_descr()`
- `test_option_consistency.test_newoption_add_in_subdescr()`
- `test_option_consistency.test_newoption_add_in_config()`
Validation upon a whole configuration object
----------------------------------------------
An option's integrity can be validated towards a whole configuration.
2012-10-05 16:00:07 +02:00
This type of validation is very open. Let's take a use case : an option
has a certain value, and the value of this option can change the owner
of another option or option group... Everything is possible.
2012-10-05 16:00:07 +02:00
For example, the configuration paths have to be unique in the
2012-11-20 17:14:58 +01:00
`glossary#schema`, the validation is carried out at the
`config.Config._cfgimpl_build()` time in the
`config.Config._validate_duplicates()` method.
2012-10-05 16:00:07 +02:00
Other hook are availables to validate upon a whole configuration at any
time.