2012-07-13 09:40:48 +02:00
|
|
|
.. default-role:: literal
|
|
|
|
|
2013-08-20 16:38:06 +02:00
|
|
|
.. currentmodule:: tiramisu
|
|
|
|
|
2013-05-21 11:37:39 +02:00
|
|
|
The global consistency
|
2013-08-20 16:38:06 +02:00
|
|
|
===========================
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2012-10-05 16:00:07 +02:00
|
|
|
Identical option names
|
|
|
|
----------------------
|
|
|
|
|
2013-08-20 17:30:24 +02:00
|
|
|
If an :class:`~option.Option()` happens to be defined twice in the
|
|
|
|
:term:`schema` (e.g. the :class:`~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.
|
|
|
|
|
2012-07-13 09:40:48 +02:00
|
|
|
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
|
2013-08-20 16:38:06 +02:00
|
|
|
option's :class:`option.Option()` validator's type.
|
2012-07-13 09:40:48 +02:00
|
|
|
|
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
|
2012-07-13 09:40:48 +02:00
|
|
|
of the same type.
|
|
|
|
|
2013-08-20 16:38:06 +02:00
|
|
|
For example, an :class:`option.IntOption` validator waits for an `int` object of
|
|
|
|
course, an :class:`option.StrOption` validator waits for an `str`, vs...
|
|
|
|
|
2013-08-21 17:21:09 +02:00
|
|
|
|
|
|
|
Where are located the values
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
The entry point of the acces to the values is the :class:`setting.Setting()` of
|
|
|
|
the root configuration object, but the values are actually located in the
|
|
|
|
:class:`value.Values()` object, in order to be delegated in some kind of a
|
|
|
|
`tiramisu.storage`, which can be a in-memory storage, or a persistent (for the
|
|
|
|
time being, a sqlite3) storage.
|
|
|
|
|
|
|
|
:class:`value.Values()` is also responsible of the owners and the calculation
|
|
|
|
of the options that have callbacks.
|
|
|
|
|
2012-07-13 09:40:48 +02:00
|
|
|
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
|
2013-08-22 11:08:26 +02:00
|
|
|
just an example, the possibilities are hudge.
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-08-22 11:08:26 +02:00
|
|
|
A requirement is a list of dictionnaries that have fairly this form::
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-08-22 11:08:26 +02:00
|
|
|
[{'option': a, 'expected': False, 'action': 'disabled', 'inverse': True,
|
|
|
|
'transitive':True, 'same_action': True}]
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-08-22 11:08:26 +02:00
|
|
|
Actually a transformation is made to this dictionnary during the validation of
|
|
|
|
this requires at the :class:`~option.Option()`'s init. The dictionnairy becomes
|
|
|
|
a tuple, wich is passed to the :meth:`~setting.Settings.apply_requires()`
|
|
|
|
method. Take a look at the code to fully understand the exact meaning of the
|
|
|
|
requirements:
|
|
|
|
|
|
|
|
.. automethod:: tiramisu.setting.Settings.apply_requires
|
|
|
|
|
|
|
|
|
|
|
|
The path of the option is required, the second element is the value wich is
|
|
|
|
expected to trigger the callback, it is required too, and the third one is the
|
|
|
|
callback's action name (`hide`, `show`...), wich is a
|
|
|
|
:class:`~setting.Property()`. Requirements are validated in
|
|
|
|
:class:`setting.Setting`.
|
2012-07-13 09:40:48 +02:00
|
|
|
|
|
|
|
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
|
2012-07-13 09:40:48 +02:00
|
|
|
of another option or option group... Everything is possible.
|
|
|
|
|
2013-05-21 18:42:56 +02:00
|
|
|
.. currentmodule:: tiramisu.option
|
|
|
|
|
|
|
|
Other hooks are availables to validate upon a whole configuration at any time,
|
|
|
|
for example the consistency between two options (typically, an
|
|
|
|
:class:`IPOption` and a :class:`NetworkOption`).
|
|
|
|
|
|
|
|
Values that are calculated
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
An option that have a callback is considered to have a value that is to be
|
|
|
|
calculated.
|
|
|
|
|
|
|
|
An option's property with a `force_store_value` attribute is considered to be
|
|
|
|
modified at the first calculation.
|
|
|
|
|
|
|
|
.. automodule:: tiramisu.autolib
|
|
|
|
:members:
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-08-21 17:21:09 +02:00
|
|
|
This is the typically protocol for accessing a option's for a calculated value,
|
|
|
|
but some twisted ways are also possible, take a look at the `force_store_value`
|
|
|
|
attribute.
|
|
|
|
|
|
|
|
.. glossary::
|
|
|
|
|
|
|
|
force store value
|
|
|
|
|
|
|
|
A calculated value (that is, an option that has a callback) with the
|
|
|
|
attribute `force_store_value` enabled is considered to be modified at
|
|
|
|
the first calculation
|
|
|
|
|