Browse Source

Fix plugins Makefile.am, settings initialization and validator

Hicham Benjelloun 7 years ago
parent
commit
3d51695ea6
3 changed files with 35 additions and 25 deletions
  1. 7
    3
      lodel/plugins/Makefile.am
  2. 4
    0
      lodel/settings/settings.py
  3. 24
    22
      lodel/validator/validator.py

+ 7
- 3
lodel/plugins/Makefile.am View File

@@ -4,10 +4,14 @@ pluginsdir=$(pkgpythondir)/plugins
4 4
 lodel2confdir=$(sysconfdir)/lodel2
5 5
 
6 6
 install-data-hook:
7
-	mkdir ${DESTDIR}$(pluginsdir); cp -R * ${DESTDIR}$(pluginsdir) && rm ${DESTDIR}$(pluginsdir)/Makefile* ;\
7
+	mkdir -p ${DESTDIR}$(pluginsdir); cp -R * ${DESTDIR}$(pluginsdir) && rm ${DESTDIR}$(pluginsdir)/Makefile* ;\
8 8
 	cd ${DESTDIR}; \
9
-	mkdir -p ./$(lodel2confdir); \
10
-	ln -rs -t ${DESTDIR}$(lodel2confdir) .$(pluginsdir)
9
+	mkdir -p $(lodel2confdir); \
10
+	if [ ! -d ${DESTDIR}$(lodel2confdir)/plugins ]; \
11
+    then \
12
+        ln -rs -t ${DESTDIR}$(lodel2confdir) $(pluginsdir); \
13
+    fi
14
+
11 15
 
12 16
 uninstall-hook:
13 17
 	-rm -R ${DESTDIR}$(pluginsdir)

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

@@ -166,6 +166,10 @@ class Settings(object, metaclass=MetaSettings):
166 166
                 plugin_list += cur_list
167 167
             except TypeError:
168 168
                 plugin_list += [cur_list]
169
+
170
+        # Remove invalid plugin names
171
+        plugin_list = [plugin for plugin in plugin_list if len(plugin) > 0]
172
+
169 173
         # Checking confspecs
170 174
         for section in lodel2_specs:
171 175
             if section.lower() != section:

+ 24
- 22
lodel/validator/validator.py View File

@@ -365,29 +365,31 @@ def emfield_val(value):
365 365
 
366 366
 
367 367
 def plugin_validator(value, ptype=None):
368
-    LodelContext.expose_modules(globals(), {
369
-        'lodel.plugin.hooks': ['LodelHook']})
370
-    value = copy.copy(value)
371
-
372
-    @LodelHook('lodel2_dyncode_bootstraped')
373
-    def plugin_type_checker(hookname, caller, payload):
368
+    if value:
374 369
         LodelContext.expose_modules(globals(), {
375
-            'lodel.plugin.plugins': ['Plugin'],
376
-            'lodel.plugin.exceptions': ['PluginError']})
377
-        if value is None:
378
-            return
379
-        try:
380
-            plugin = Plugin.get(value)
381
-        except PluginError:
382
-            msg = "No plugin named %s found"
383
-            msg %= value
384
-            raise ValidationError(msg)
385
-        if plugin._type_conf_name.lower() != ptype.lower():
386
-            msg = "A plugin of type '%s' was expected but found a plugin \
387
-named  '%s' that is a '%s' plugin"
388
-            msg %= (ptype, value, plugin._type_conf_name)
389
-            raise ValidationError(msg)
390
-    return value
370
+            'lodel.plugin.hooks': ['LodelHook']})
371
+        value = copy.copy(value)
372
+
373
+        @LodelHook('lodel2_dyncode_bootstraped')
374
+        def plugin_type_checker(hookname, caller, payload):
375
+            LodelContext.expose_modules(globals(), {
376
+                'lodel.plugin.plugins': ['Plugin'],
377
+                'lodel.plugin.exceptions': ['PluginError']})
378
+            if value is None:
379
+                return
380
+            try:
381
+                plugin = Plugin.get(value)
382
+            except PluginError:
383
+                msg = "No plugin named %s found"
384
+                msg %= value
385
+                raise ValidationError(msg)
386
+            if plugin._type_conf_name.lower() != ptype.lower():
387
+                msg = "A plugin of type '%s' was expected but found a plugin \
388
+    named  '%s' that is a '%s' plugin"
389
+                msg %= (ptype, value, plugin._type_conf_name)
390
+                raise ValidationError(msg)
391
+        return value
392
+    return None
391 393
 
392 394
 
393 395
 Validator.register_validator(

Loading…
Cancel
Save