Quellcode durchsuchen

Fixing multisite loading process & dyncode bootstrapping

- a "normal" import was left in lefactory_common
- the hook triggering datasources init in dyncode was not called
- dyncode was not exposed in the loader (making hook call useless : the hook has to be called once the dyncode has been "seen" (imported) by python)
Yann Weber vor 8 Jahren
Ursprung
Commit
a21e0be25f
4 geänderte Dateien mit 9 neuen und 5 gelöschten Zeilen
  1. 1
    1
      README
  2. 2
    2
      lodel/context.py
  3. 1
    2
      lodel/leapi/lefactory_common.py
  4. 5
    0
      lodel/plugins/multisite/loader.py

+ 1
- 1
README Datei anzeigen

@@ -130,7 +130,7 @@ Mass deployments tricks & tips:
130 130
 	#Reactivate auth
131 131
 	sed -i -e 's/^noauth = /#noauth =/' -e 's/^#auth = /auth =/' /etc/mongodb.conf
132 132
 	#Test connection
133
-	echo "exit" | mongo --quiet -u $mongoadmin -p $mongopass admin && echo "Connection ok" || echo "connection fails"
133
+	echo "exit" | mongo --quiet -u $mongoadmin -p $mongopass admin && echo "Connection ok" || echo "connection fails"
134 134
 	#Indicate mongodb credentials to mass_deploy
135 135
 	echo -e "MONGODB_ADMIN_USER='$mongoadmin'\nMONGODB_ADMIN_PASSWORD='$mongopass'\n" >> /etc/lodel2/mass_deploy.cfg
136 136
 	#Deploying 50 instances

+ 2
- 2
lodel/context.py Datei anzeigen

@@ -69,8 +69,8 @@ class LodelMetaPathFinder(importlib.abc.MetaPathFinder):
69 69
     
70 70
     def find_spec(fullname, path, target = None):
71 71
         if fullname.startswith(CTX_PKG):
72
-            print("find_spec called : fullname=%s path=%s target=%s" % (
73
-                fullname, path, target))
72
+            #print("find_spec called : fullname=%s path=%s target=%s" % (
73
+            #    fullname, path, target))
74 74
             spl = fullname.split('.')
75 75
             site_identifier = spl[1]
76 76
             #creating a symlink to represent the lodel site package

+ 1
- 2
lodel/leapi/lefactory_common.py Datei anzeigen

@@ -5,7 +5,6 @@
5 5
 #- All lines that begins with #- will be deleted from dynamically generated
6 6
 #- code...
7 7
 
8
-
9 8
 ##@brief Return a dynamically generated class given it's name
10 9
 #@param name str : The dynamic class name
11 10
 #@return False or a child class of LeObject
@@ -32,6 +31,6 @@ def lowername2class(name):
32 31
 def lodel2_dyncode_datasources_init(self, caller, payload):
33 32
     for cls in dynclasses:
34 33
         cls._init_datasources()
35
-    from lodel.plugin.hooks import LodelHook
34
+    LodelContext.expose_modules(globals(), {'lodel.plugin.hooks': ['LodelHook']})
36 35
     LodelHook.call_hook("lodel2_dyncode_loaded", __name__, dynclasses)
37 36
 

+ 5
- 0
lodel/plugins/multisite/loader.py Datei anzeigen

@@ -39,6 +39,11 @@ for lodelsite_path in lodelsites_list:
39 39
         'lodel.plugin': ['Plugin']})
40 40
     logger.debug("Loader.start() called")
41 41
     Plugin.load_all()
42
+    #Import & expose dyncode
43
+    LodelContext.expose_dyncode(globals())
44
+    #Next hook triggers dyncode datasource instanciations
45
+    LodelHook.call_hook('lodel2_plugins_loaded', '__main__', None)
46
+    #Next hook triggers call of interface's main loop
42 47
     LodelHook.call_hook('lodel2_bootstraped', '__main__', None)
43 48
     #switch back to loader context
44 49
     LodelContext.set(None)

Laden…
Abbrechen
Speichern