Bladeren bron

Implements inconsistency detection between db & fs

In multisite loader utils
Yann Weber 7 jaren geleden
bovenliggende
commit
a567abc187
1 gewijzigde bestanden met toevoegingen van 9 en 8 verwijderingen
  1. 9
    8
      lodel/plugins/multisite/loader_utils.py

+ 9
- 8
lodel/plugins/multisite/loader_utils.py Bestand weergeven

@@ -2,13 +2,6 @@ import os
2 2
 import os.path
3 3
 
4 4
 
5
-##@brief basename of multisite process conf folder
6
-#@todo find a better place to declare it
7
-SERVER_CONFD = 'server_conf.d' #Should be accessible elsewhere
8
-##@brief basename of lodelsites site conf folder
9
-#@todo find a better place to declare it
10
-LODELSITES_CONFD = 'lodelsites.conf.d' #Should be accessible elsewhere
11
-
12 5
 ##@brief A cache allowing a fast application exposure
13 6
 #
14 7
 #This dict contains reference on interface module of each handled site in
@@ -22,8 +15,9 @@ except ImportError:
22 15
         os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
23 16
     from lodel.context import LodelContext, ContextError
24 17
 
25
-
26 18
 import lodel.buildconf
19
+##@brief basename of lodelsites site conf folder
20
+LODELSITES_CONFD = lodel.buildconf.LODELSITE_CONFDIR
27 21
 
28 22
 ##@brief Stores the main function of a multisite loader
29 23
 
@@ -44,6 +38,9 @@ def main():
44 38
     LodelContext.expose_modules(globals(), {
45 39
         'lodel.settings': ['Settings']})
46 40
     lodelsites_name = Settings.sitename
41
+    lodelsites_datapath = os.path.join(
42
+    	os.path.join(lodel.buildconf.LODEL2VARDIR, lodelsites_name),
43
+	lodel.buildconf.MULTISITE_DATADIR)
47 44
     del(globals()['Settings'])
48 45
     
49 46
     #bootstraping the lodelsites instance
@@ -127,6 +124,10 @@ sux !')
127 124
     #Determining uniq sitename from data_path
128 125
     data_path = data_path.rstrip('/') #else basename returns ''
129 126
     ctx_name = os.path.basename(data_path)
127
+    if not os.path.exists(data_path) or not os.path.isdir(data_path):
128
+        LodelContext.expose_modules(globals(), {
129
+            'lodel.exceptions': ['LodelFatalError']})
130
+        raise LodelFatalError("A site named '%s' was found in the DB but not on the FS (expected to found it in '%s'!!!" % (os.path.basename(data_path), data_path))
130 131
     #Immediately switching to the context
131 132
     LodelContext.new(ctx_name)
132 133
     LodelContext.set(ctx_name)

Loading…
Annuleren
Opslaan