Statistics
| Branch: | Tag: | Revision:

root / snf-app / docs / src / snf-common.rst @ 252bb277

History | View | Annotate | Download (2 kB)

1
.. _snf-common:
2

    
3
Component snf-common
4
--------------------
5

    
6
synnefo component :ref:`snf-common <snf-common>` defines a mechanism for
7
handling configuration settings, shared among all synnefo components. It also
8
defines default values for a number of common settings.
9

    
10
The final values of synnefo settings result from applying custom admin-defined
11
modifications to the default values specified by the various components.
12
:ref:`snf-common <snf-common>` provides a mechanism for discovering default
13
settings, which it then amends with user-provided configuration to provide the
14
final ``settings`` object.
15

    
16
Default settings
17
    Component ``snf-common`` provides a number of defaults in Python module
18
    ``synnefo.common.settings``. Every other component may extend the
19
    ``synnefo`` namespace package and provide an ``extend_settings()`` entry
20
    point in group ``synnefo.settings.FIXME``. The common settings initialization
21
    code calls all such endpoints one by one, to assemble the defaults.
22
User settings
23
    The administrator can modify any setting at will, using ``*.conf`` files
24
    under ``$SYNNEFO_SETTINGS_DIR``, which defaults to ``/etc/synnefo``.
25
    Code in `snf-common` executes all ``*.conf`` files in lexicographic
26
    order, as standard Python code, after assembling the set of defaults.
27

    
28
synnefo settings are usable as Django settings, when in a Django
29
context, or as a standard Python module when not using Django. This avoids
30
an unecessary dependendy on Django.
31

    
32
To use synnefo settings with Django, have ``$DJANGO_SETTINGS_MODULE`` point
33
to the ``synnefo.settings`` module
34

    
35
.. code-block:: console
36

    
37
    $ export DJANGO_SETTINGS_MODULE=synnefo.settings
38

    
39
then import Django settings as usual:
40

    
41
.. code-block:: python
42

    
43
    from django.conf import settings
44

    
45
When not in a Django context, import the ``synnefo.settings`` module directly:
46

    
47
.. code-block:: python
48

    
49
    from synnefo import settings
50

    
51
In both cases, assembly of default settings and execution of
52
``$SYNNEFO_SETTINGS_DIR/*.conf`` happens in the same way.