2012-07-13 09:40:48 +02:00
|
|
|
==================================
|
2013-05-17 12:11:14 +02:00
|
|
|
Getting started
|
2012-07-13 09:40:48 +02:00
|
|
|
==================================
|
|
|
|
|
2013-08-23 11:16:26 +02:00
|
|
|
What is options handling ?
|
2012-11-20 17:14:58 +01:00
|
|
|
=================================
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-08-29 11:48:34 +02:00
|
|
|
Due to more and more available options required to set up an operating system,
|
|
|
|
compiler options or whatever, it became quite annoying to hand the necessary
|
|
|
|
options to where they are actually used and even more annoying to add new
|
|
|
|
options. To circumvent these problems the configuration control was
|
2013-08-23 11:16:26 +02:00
|
|
|
introduced...
|
2012-07-13 09:40:48 +02:00
|
|
|
|
|
|
|
What is Tiramisu ?
|
2012-11-20 17:14:58 +01:00
|
|
|
===================
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-08-23 11:42:22 +02:00
|
|
|
Tiramisu is an options handler and an options controller, wich aims at
|
|
|
|
producing flexible and fast options access. The main advantages are its access
|
2013-08-23 11:16:26 +02:00
|
|
|
rules and the fact that the whole consistency is preserved at any time, see
|
2013-08-23 11:42:22 +02:00
|
|
|
:doc:`consistency`. There is of course type and structure validations, but also
|
2013-08-29 11:48:34 +02:00
|
|
|
validations towards the whole options. Furthermore, options can be reached and
|
|
|
|
changed according to the access rules from nearly everywhere in your appliance.
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2012-11-20 17:14:58 +01:00
|
|
|
Just the facts
|
|
|
|
==============
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2012-11-20 17:14:58 +01:00
|
|
|
.. _gettingtiramisu:
|
2012-07-13 09:40:48 +02:00
|
|
|
|
|
|
|
Download
|
|
|
|
---------
|
|
|
|
|
2013-08-23 11:42:22 +02:00
|
|
|
To obtain a copy of the sources, check it out from the repository using `git`.
|
2013-08-29 11:48:34 +02:00
|
|
|
We suggest using `git` if one wants to access to the current developments.
|
2012-07-13 09:40:48 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
git clone git://git.labs.libre-entreprise.org/tiramisu.git
|
|
|
|
|
2013-08-23 11:42:22 +02:00
|
|
|
This will get you a fresh checkout of the code repository in a local directory
|
2013-05-15 17:35:49 +02:00
|
|
|
named ``tiramisu``.
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-05-15 17:35:49 +02:00
|
|
|
Getting started
|
|
|
|
-------------------
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-08-23 11:42:22 +02:00
|
|
|
Option objects can be created in different ways. Let's perform very basic
|
|
|
|
:class:`~tiramisu.option.Option` and :class:`~tiramisu.config.Config` object
|
2013-08-23 11:16:26 +02:00
|
|
|
manipulations:
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-05-15 17:35:49 +02:00
|
|
|
::
|
2012-07-13 09:40:48 +02:00
|
|
|
|
2013-05-15 17:35:49 +02:00
|
|
|
>>> from tiramisu.config import Config
|
|
|
|
>>> from tiramisu.option import OptionDescription, BoolOption
|
2013-08-29 11:48:34 +02:00
|
|
|
>>> # let's create a group of options... with only one option inside
|
2013-05-15 17:35:49 +02:00
|
|
|
>>> descr = OptionDescription("optgroup", "", [
|
|
|
|
... BoolOption("bool", "", default=False)])
|
2013-08-29 11:48:34 +02:00
|
|
|
>>> # c is a namespace as well as a container for the options
|
2013-08-23 11:42:22 +02:00
|
|
|
>>> c = Config(descr)
|
|
|
|
>>> c.bool
|
2013-05-15 17:35:49 +02:00
|
|
|
False
|
2013-08-23 11:42:22 +02:00
|
|
|
>>> c.bool = True
|
|
|
|
>>> c.bool
|
2013-05-15 17:35:49 +02:00
|
|
|
True
|
|
|
|
|
2013-08-29 11:48:34 +02:00
|
|
|
So by now, we have:
|
2013-05-15 17:35:49 +02:00
|
|
|
|
2013-08-23 11:42:22 +02:00
|
|
|
- a namespace (which is `c` here)
|
2013-05-15 17:35:49 +02:00
|
|
|
- the access of an option's value by the
|
2013-08-29 11:48:34 +02:00
|
|
|
attribute access way (here `bool`, wich is a boolean option
|
2013-08-23 11:42:22 +02:00
|
|
|
:class:`~tiramisu.option.BoolOption()`.
|
2013-05-15 17:35:49 +02:00
|
|
|
|
2013-08-29 11:48:34 +02:00
|
|
|
So, option objects are produced at the entry point `c` and then handed down to
|
|
|
|
where they are actually used when `c.bool` is triggered. This keeps options
|
|
|
|
local but available at any timer and consistent.
|
2013-08-23 11:42:22 +02:00
|
|
|
|
2013-08-29 11:48:34 +02:00
|
|
|
Once the namespace is created, we can set a
|
|
|
|
:meth:`~config.CommonConfig.read_write()` access to the options::
|
2013-08-23 11:42:22 +02:00
|
|
|
|
|
|
|
>>> c.read_write()
|
2013-08-29 11:48:34 +02:00
|
|
|
|
|
|
|
which enables us to set a bunch of access rules that we wil explain later in
|
|
|
|
:doc:`status`.
|