|
@@ -238,37 +238,25 @@ def emfield_val(value):
|
238
|
238
|
msg = "Following field not found in class %s : %s"
|
239
|
239
|
raise SettingsValidationError(msg % value)
|
240
|
240
|
return value
|
241
|
|
-
|
242
|
|
-def plugin_val(value):
|
243
|
|
- #Late validation hook
|
244
|
|
- @LodelHook('lodel2_dyncode_bootstraped')
|
245
|
|
- def plugin_check(hookname, caller, payload):
|
246
|
|
- from lodel import plugin
|
247
|
|
- for inst in plugin._plugin_instances:
|
248
|
|
- if (not isinstance(value, inst)):
|
249
|
|
- msg = "Following plugin types do not exists in the loader: %s"
|
250
|
|
- raise SettingsValidationError(msg % value)
|
251
|
|
- return value
|
252
|
241
|
|
253
|
|
-def plugins_val(value):
|
254
|
|
- spl = value.split('.')
|
255
|
|
- if len(spl) < 1:
|
256
|
|
- msg = "Expected a value in the form PLUGIN.NAME or PLUGIN.VERSION but got : %s"
|
|
242
|
+def plugin_val(value):
|
|
243
|
+ if spl = value.split('.')
|
|
244
|
+ if len(spl) != 2:
|
|
245
|
+ msg = "Expected a value in the form PLUGIN.TYPE but got : %s"
|
257
|
246
|
raise SettingsValidationError(msg % value)
|
258
|
247
|
value = tuple(spl)
|
259
|
|
- #Late validation hook
|
260
|
|
- @LodelHook('lodel2_dyncode_bootstraped')
|
261
|
|
- def plugin_check(hookname, caller, payload):
|
262
|
|
- from lodel import plugin
|
263
|
|
- pluginnames = { cls.__type.lower():cls for cls in dyncode.dynclasses}
|
264
|
|
- if value[0].lower() not in pluginsnames:
|
265
|
|
- msg = "Following plugin types do not exists in the loader: %s"
|
266
|
|
- raise SettingsValidationError(msg % value[0])
|
267
|
|
- ccls = classnames[value[0].lower()]
|
268
|
|
- if value[1].lower() not in ccls.fieldnames(True):
|
269
|
|
- msg = "Following field not found in class %s : %s"
|
270
|
|
- raise SettingsValidationError(msg % value)
|
271
|
|
- return value
|
|
248
|
+ #Late validation hook
|
|
249
|
+ @LodelHook('lodel2_dyncode_bootstraped')
|
|
250
|
+ def type_check(hookname, caller, payload):
|
|
251
|
+ from lodel import plugin
|
|
252
|
+ typesname = { cls.__name__.lower():cls for cls in plugin.PLUGINS_TYPE}
|
|
253
|
+ if value[1].lower() not in typesname:
|
|
254
|
+ msg = "Following plugin type do not exist in plugin list %s : %s"
|
|
255
|
+ raise SettingsValidationError(msg % value)
|
|
256
|
+ return value
|
|
257
|
+ plug_type_val = plugin_val(value)
|
|
258
|
+ return plug_type_val
|
|
259
|
+
|
272
|
260
|
|
273
|
261
|
#
|
274
|
262
|
# Default validators registration
|