Browse Source

Merged server.conf.d and lodelsites_conf.d for lodelsites

Now both __loader__ and lodelsites contexts are using the same configuration
files and the same confspecs.
Yann Weber 7 years ago
parent
commit
f9ade94a06

+ 16
- 8
lodel/bootstrap.py View File

@@ -20,6 +20,9 @@ from lodel.context import LodelContext
20 20
 #First item is for monosite the second for multisite
21 21
 #First item for multisite is server conf the second the lodelsites instance
22 22
 #conf
23
+#
24
+#@note obsolete ! We are preparing a merge of server_conf.d and 
25
+#lodelsites.conf.d
23 26
 CONFS_DIRNAMES = [
24 27
     'conf.d',
25 28
     ('server_conf.d', 'lodelsites.conf.d')]
@@ -42,12 +45,14 @@ def _context_initialisation():
42 45
 def _get_confdir(ctx_type):
43 46
     if _monosite_test():
44 47
         return CONFS_DIRNAMES[0]
45
-    elif ctx_type == '__loader__':
46
-        return CONFS_DIRNAMES[1][0]
47
-    elif ctx_type == 'lodelsites':
48
-        return CONFS_DIRNAMES[1][1]
49
-    raise ValueError("ctx_type is not one of '__loader__' nor 'lodelsites' \
50
-authorized values")
48
+    return CONFS_DIRNAMES[1][1]
49
+
50
+    #elif ctx_type == '__loader__':
51
+    #    return CONFS_DIRNAMES[1][0]
52
+    #elif ctx_type == 'lodelsites':
53
+    #    return CONFS_DIRNAMES[1][1]
54
+    #raise ValueError("ctx_type is not one of '__loader__' nor 'lodelsites' \
55
+    #authorized values")
51 56
 
52 57
 ##@brief Return confspec associated with current context & context type
53 58
 #@param ctx_type str 
@@ -90,8 +95,11 @@ MONOSITE instance")
90 95
         'lodel.settings.settings': [('Settings', 'settings_loader')],
91 96
         'lodel.plugins.multisite.confspecs': 'multisite_confspecs'})
92 97
     
93
-    settings_loader(confdir, custom_confspecs)
94
-    del(globals()['settings'])
98
+    if ctx_type is not None:
99
+        settings_loader(confdir, custom_confspecs, True) #Append specs
100
+    else:
101
+        settings_loader(confdir, custom_confspecs)
102
+    del(globals()['settings_loader'])
95 103
 
96 104
     LodelContext.expose_modules(globals(), {
97 105
         'lodel.settings': ['Settings']})

+ 4
- 22
lodel/plugins/multisite/confspecs.py View File

@@ -2,14 +2,12 @@ from lodel.context import LodelContext
2 2
 LodelContext.expose_modules(globals(), {
3 3
     'lodel.validator.validator': ['Validator']})
4 4
 
5
-#Define a minimal confspec used by multisite loader
5
+#Define a minimal confspec used by multisite loader and by lodelsites
6
+#instance
6 7
 LODEL2_CONFSPECS = {
7
-    'lodel2': {
8
-        'debug': (True, Validator('bool')),
9
-    },
10 8
     'lodel2.lodelsites': {
11
-        'name': (None,
12
-            Validator('string', none_is_valid = False)), #Bad validator
9
+        #'name': (None,
10
+        #    Validator('string', none_is_valid = False)), #replaced by lodel2.name
13 11
         'lodelsites_emfile': (None,
14 12
             Validator('string', none_is_valid = False)), #Bad validator
15 13
         'lodelsites_emtranslator': ('picklefile',
@@ -19,20 +17,4 @@ LODEL2_CONFSPECS = {
19 17
         'sites_emtranslator': ('picklefile',
20 18
             Validator('string', none_is_valid = False)), #Bad validator
21 19
     },
22
-    'lodel2.logging.*' : {
23
-        'level': (  'ERROR',
24
-                    Validator('loglevel')),
25
-        'context': (    False,
26
-                        Validator('bool')),
27
-        'filename': (   None,
28
-                        Validator('errfile', none_is_valid = True)),
29
-        'backupcount': (    10,
30
-                            Validator('int', none_is_valid = False)),
31
-        'maxbytes': (   1024*10,
32
-                        Validator('int', none_is_valid = False)),
33
-    },
34
-    'lodel2.datasources.*': {
35
-        'read_only': (False, Validator('bool')),
36
-        'identifier': ( None, Validator('string')),
37
-    }
38 20
 }

+ 14
- 4
lodel/settings/settings.py View File

@@ -82,17 +82,25 @@ class Settings(object, metaclass=MetaSettings):
82 82
     #  @brief Stores the singleton instance
83 83
     instance = None
84 84
 
85
-    #  @brief Instanciate the Settings singleton
86
-    # @param conf_dir str : The configuration directory
85
+    ##@brief Instanciate the Settings singleton
86
+    #@param conf_dir str : The configuration directory
87 87
     #@param custom_confspecs None | dict : if given overwrite default lodel2
88 88
     # confspecs
89
-    def __init__(self, conf_dir, custom_confspecs=None):
89
+    #@param append bool : if true do not replace LODEL2CONFSPECS by
90
+    #custom_confspecs, append them instead
91
+    #
92
+    #@todo append param and __custom_specs_append attributes are quick
93
+    #workarounds in order to be able to specialise LODEL2_CONF_SPECS for a 
94
+    #multisite lodelsite. This should be done using the standard confspecs
95
+    #mechanism available using plugins
96
+    def __init__(self, conf_dir, custom_confspecs=None, append = False):
90 97
         self.singleton_assert()  # check that it is the only instance
91 98
         Settings.instance = self
92 99
         #  @brief Configuration specification
93 100
         #
94 101
         # Initialized by Settings.__bootstrap() method
95
-        self.__conf_specs = custom_confspecs
102
+        self.__conf_specs = custom_confspecs if not append else None
103
+        self.__conf_specs_append = custom_confspecs if append else None
96 104
         #  @brief Stores the configurations in namedtuple tree
97 105
         self.__confs = None
98 106
         self.__conf_dir = conf_dir
@@ -181,6 +189,8 @@ class Settings(object, metaclass=MetaSettings):
181 189
         Plugin.start(plugin_list)
182 190
         # Fetching conf specs from plugins
183 191
         specs = [lodel2_specs]
192
+        if self.__conf_specs_append is not None:
193
+            specs.append(self.__conf_specs_append)
184 194
         errors = list()
185 195
         for plugin_name in plugin_list:
186 196
             try:

+ 1
- 3
lodel/validator/validator.py View File

@@ -405,7 +405,7 @@ Validator.register_validator(
405 405
 #   Lodel 2 configuration specification
406 406
 #
407 407
 
408
-# @brief Append a piece of confspec
408
+##@brief Append a piece of confspec
409 409
 #@note orig is modified during the process
410 410
 #@param orig dict : the confspec to update
411 411
 #@param section str : section name
@@ -413,8 +413,6 @@ Validator.register_validator(
413 413
 #@param validator Validator : the validator to use to check this configuration key's value
414 414
 #@param default
415 415
 #@return new confspec
416
-
417
-
418 416
 def confspec_append(orig, section, key, validator, default):
419 417
     if section not in orig:
420 418
         orig[section] = dict()

+ 0
- 2
progs/slim/Makefile.am View File

@@ -22,8 +22,6 @@ multisite_install_model__DATA = multisite_install_model/Makefile \
22 22
 
23 23
 multisite_lodelsites_conf_dir = $(multisite_install_model_dir)/lodelsites.conf.d
24 24
 multisite_lodelsites_conf__DATA = multisite_install_model/lodelsites.conf.d/lodel2.ini
25
-multisite_server_conf_dir = $(multisite_install_model_dir)/server_conf.d
26
-multisite_server_conf__DATA = multisite_install_model/server_conf.d/lodel2.ini
27 25
 
28 26
 
29 27
 slim_conf_model_dir = $(install_model_dir)/conf.d/

+ 4
- 0
progs/slim/multisite_install_model/lodelsites.conf.d/lodel2.ini View File

@@ -14,6 +14,10 @@ emfile = editorial_model.pickle
14 14
 #emtranslator = externaly_handled
15 15
 dyncode = leapi_dyncode.py
16 16
 
17
+[lodel2.lodelsites]
18
+sites_emfile = sites_em.pickle
19
+lodelsites_emfile = editorial_model.pickle
20
+
17 21
 [lodel2.datasource.lodelsite_datasource.default]
18 22
 db_datasource = mongo
19 23
 

+ 0
- 22
progs/slim/multisite_install_model/server_conf.d/lodel2.ini View File

@@ -1,22 +0,0 @@
1
-[lodel2]
2
-debug = False
3
-datasource_connectors = mongodb_datasource lodelsite_datasource
4
-session_handler = filesystem_session
5
-
6
-[lodel2.datasource.lodelsite_datasource.default]
7
-db_datasource = mongo
8
-
9
-[lodel2.datasources.default]
10
-identifier = dummy_datasource.default
11
-
12
-[lodel2.datasources.dummy2]
13
-identifier = dummy_datasource.default
14
-
15
-[lodel2.datasource.dummy_datasource.default]
16
-dummy =
17
-
18
-[lodel2.logging.default]
19
-context = True
20
-filename = -
21
-level = DEBUG
22
-

Loading…
Cancel
Save