summaryrefslogtreecommitdiff
path: root/docs/source/docs/architecture/config.rst
blob: 768a7adb03a9077b285502cb2e030cd173cc1939 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
.. _reconfig:

Reconfig objects
****************

:class:`reconfigure.config.Reconfig` objects are pre-set pipelines connecting :ref:`Parsers <parser>`, :ref:`Includers <includer>` and :ref:`Builders <builder>`

Reconfigure comes with many Reconfig objects out-of-the-box - see :ref:`reconfigure.configs`

Writing your Reconfig subclass
==============================

Use the following pattern::

    class <name>Config (Reconfig):
        """
        <description>
        """

        def __init__(self, **kwargs):
            k = {
                'parser': <parser-class>(),
                'includer': <includer-class>(),
                'builder': BoundBuilder(<root-data-class>),
            }
            k.update(kwargs)
            Reconfig.__init__(self, **k)

Example::

    class SupervisorConfig (Reconfig):
        """
        ``/etc/supervisor/supervisord.conf``
        """

        def __init__(self, **kwargs):
            k = {
                'parser': IniFileParser(),
                'includer': SupervisorIncluder(),
                'builder': BoundBuilder(SupervisorData),
            }
            k.update(kwargs)
            Reconfig.__init__(self, **k)