Browse Source

Fixing multisite loader

Now it seems to work. Tested using :
dummy datasource, no handled sites, ipython ui
Yann Weber 7 years ago
parent
commit
5467df8184
2 changed files with 23 additions and 29 deletions
  1. 2
    2
      lodel/leapi/leobject.py
  2. 21
    27
      lodel/plugins/multisite/loader_utils.py

+ 2
- 2
lodel/leapi/leobject.py View File

@@ -275,7 +275,7 @@ class LeObject(object):
275 275
         if cls._ro_datasource is None:
276 276
             log_msg = "No read only datasource set for LeObject %s"
277 277
             log_msg %= cls.__name__
278
-            logger.debug(log_msg)
278
+            logger.error(log_msg)
279 279
         else:
280 280
             log_msg = "Read only datasource '%s' initialized for LeObject %s"
281 281
             log_msg %= (ro_ds, cls.__name__)
@@ -285,7 +285,7 @@ class LeObject(object):
285 285
         if cls._ro_datasource is None:
286 286
             log_msg = "No read/write datasource set for LeObject %s"
287 287
             log_msg %= cls.__name__
288
-            logger.debug(log_msg)
288
+            logger.error(log_msg)
289 289
         else:
290 290
             log_msg = "Read/write datasource '%s' initialized for LeObject %s"
291 291
             log_msg %= (ro_ds, cls.__name__)

+ 21
- 27
lodel/plugins/multisite/loader_utils.py View File

@@ -37,26 +37,6 @@ import lodel.buildconf
37 37
 #@todo use the dyncode getter when it will be available (replaced by
38 38
 #the string SUPERDYNCODE_ACCESSOR.Lodelsite for the moment)
39 39
 def main():
40
-    """
41
-    LodelContext.set(None)
42
-    LodelContext.expose_modules(globals(), {
43
-        'lodel.logger': 'logger',
44
-        'lodel.exceptions': ['LodelFatalError'],
45
-    })
46
-    
47
-    CONFDIR = os.path.join(os.getcwd(), SERVER_CONFD)
48
-    if not os.path.isdir(CONFDIR):
49
-        logger.critical('Multisite process bootstraping fails : unable to \
50
-find the %s folder' % SERVER_CONFD)
51
-    
52
-    #Settings bootstraping for mutlisite process
53
-    LodelContext.expose_modules(globals(), {
54
-        'lodel.settings.settings': [('Settings', 'settings')],
55
-        'lodel.plugins.multisite.confspecs': 'multisite_confspecs'})
56
-    settings(CONFDIR, multisite_confspecs.LODEL2_CONFSPECS)
57
-    #Loading settings
58
-    del(globals()['settings']) #useless but may be safer
59
-    """
60 40
     #Set current context to reserved loader context
61 41
     from lodel import bootstrap
62 42
     bootstrap.bootstrap('__loader__')
@@ -81,6 +61,15 @@ find the %s folder' % SERVER_CONFD)
81 61
         'lodel.settings': ['Settings']})
82 62
 
83 63
     LodelContext.expose_dyncode(globals())
64
+
65
+    LodelContext.expose_modules(globals(), {
66
+        'lodel.logger': 'logger',
67
+        'lodel.plugin.hooks': ['LodelHook'],
68
+        'lodel.plugin': ['Plugin']})
69
+    Plugin.load_all()
70
+    LodelHook.call_hook('lodel2_bootstraped', '__main__', None)
71
+
72
+
84 73
     lodelsite_leo = leapi_dyncode.Lodelsite #hardcoded leo name
85 74
     LodelContext.expose_modules(globals(), {
86 75
         'lodel.leapi.query': ['LeGetQuery'],
@@ -88,16 +77,21 @@ find the %s folder' % SERVER_CONFD)
88 77
     #the line bellow you will find another harcoded thing : the shortname
89 78
     #fieldname for a lodelsite
90 79
     handled_sites = LeGetQuery(lodelsite_leo, query_filters = [],
91
-        field_list = ['shortname'])
80
+        field_list = ['shortname']).execute()
92 81
     #Now that we have the handled sitenames list we can go back to
93 82
     #loader context and clean it
83
+    if handled_sites is not None:
84
+        LodelContext.set(None)
85
+        for mname in ['LeGetQuery', 'Settings', 'LodelHook', 'Plugin', 'logger']:
86
+            del(globals()[mname])
87
+        #Loading handled sites
88
+        for handled_sitename in [s['shortname'] for s in handled_sites]:
89
+            datapath = os.path.join(lodelsites_datapath, handled_sitename)
90
+            site_load(datapath) #using default conf.d configuration dirname
91
+    else:
92
+        logger.warning("No handled sites !")
94 93
     LodelContext.set(None)
95
-    for mname in ['LeGetQuery', 'Settings']:
96
-        del(globals()[mname])
97
-    #Loading handled sites
98
-    for handled_sitename in [s['shortname'] for s in handled_sites]:
99
-        datapath = os.path.join(lodelsites_datapath, handled_sitename)
100
-        site_load(datapath) #using default conf.d configuration dirname
94
+        
101 95
     
102 96
 
103 97
 ##@brief Load a site

Loading…
Cancel
Save