Browse Source

Bugfixing lodelsites datasource

Yann Weber 7 years ago
parent
commit
97b59379f4

+ 6
- 6
lodel/plugins/lodelsite_datasource/fs_utils.py View File

@@ -43,7 +43,7 @@ def name2path(name):
43 43
 #@return a bool
44 44
 #@throws LodelSiteDatasourceInconsistency if inconsistency detected on FS
45 45
 def site_exists(name):
46
-    paths = name2paths(name)
46
+    paths = name2path(name)
47 47
     
48 48
     if name == Settings.sitename:
49 49
         msg = 'Site shortname "%s" is conflicting with the Lodelsites instance name' % name
@@ -79,7 +79,7 @@ def site_directories_creation(name):
79 79
         raise LodelSiteDatasourceError('This site identified by "%s" \
80 80
 already exists' % name)
81 81
 
82
-    data_path, ctx_path = name2paths(name)
82
+    data_path, ctx_path = name2path(name)
83 83
     #Starting by creating both directories
84 84
     #Datadir
85 85
     try:
@@ -118,8 +118,8 @@ lodelsite "%s" : %s' % (d,name, e))
118 118
     
119 119
     
120 120
 def site_lodelpkg_link_creation(name):
121
-    dst_path = os.path.join(name2path(name)[1], lodel)
122
-    src_path = LODEL_PKG_PATH
121
+    dst_path = os.path.join(name2path(name)[1], 'lodel')
122
+    src_path = buildconf.LODEL_PKG_PATH
123 123
     
124 124
     try:
125 125
         os.symlink(src_path, dst_path)
@@ -135,7 +135,7 @@ lodelsite "%s" : %s' % (name, e))
135 135
 def site_context_init_creation(name):
136 136
     directory = name2path(name)[1]
137 137
     try:
138
-        open('x', os.path.join(directory, '__init__.py')).close()
138
+        open(os.path.join(directory, '__init__.py'), 'w+').close()
139 139
     except FileExistsError:
140 140
         logger.critical('This should never happen ! We just checked that this \
141 141
 directory does not exist. BAILOUT !')
@@ -210,7 +210,7 @@ def make_confs(sitename, groups, extensions):
210 210
 ##@brief Deletes all files related to a site
211 211
 #@warning can lead to dirty bugs if the site is running...
212 212
 def purge(sitename):
213
-    for todel in name2paths(sitename):
213
+    for todel in name2path(sitename):
214 214
         try:
215 215
             shutil.rmtree(todel)
216 216
         except Exception as e:

+ 1
- 1
lodel/plugins/lodelsite_datasource/sites_utils.py View File

@@ -20,7 +20,7 @@ def update_dyncode(site_name, em_groups):
20 20
     _, ctx_path = LodelContext.lodelsites_paths()
21 21
     dyncode_path = os.path.join(os.path.join(ctx_path, site_name),
22 22
             buildconf.MULTISITE_DYNCODE_MODULENAME+'.py')
23
-    LodelContext.expose_module(globals(), {
23
+    LodelContext.expose_modules(globals(), {
24 24
             'lodel.logger': 'logger',
25 25
             'lodel.settings': ['Settings'],
26 26
             'lodel.editorial_model.model': ['EditorialModel'],

+ 12
- 1
lodel/plugins/multisite/loader_utils.py View File

@@ -84,7 +84,18 @@ def main():
84 84
         #Loading handled sites
85 85
         for handled_sitename in [s['shortname'] for s in handled_sites]:
86 86
             datapath = os.path.join(lodelsites_datapath, handled_sitename)
87
-            site_load(datapath) #using default conf.d configuration dirname
87
+            try:
88
+                site_load(datapath) #using default conf.d configuration dirname
89
+            except LodelFatalError as e:
90
+                LodelContext.set(lodelsites_name)
91
+                LodelContext.expose_modules(globals(), {
92
+                    'lodel.settings': ['Settings'],
93
+                    'lodel.logger': 'logger'})
94
+                if Settings.debug:
95
+                    logger.critical("Unable to load site %s : %s" % (
96
+                        e, handled_sitename))
97
+                else:
98
+                    raise e
88 99
     else:
89 100
         logger.warning("No handled sites !")
90 101
     LodelContext.set(None)

Loading…
Cancel
Save