1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-11-26 07:16:54 +01:00

Documentation on datasources plugins + confspec updates in validator.py

+ a new validator named 'string', it tries to cast the conf value using str()
This commit is contained in:
Yann 2016-05-25 15:08:00 +02:00
commit 6fb04a69fb
3 changed files with 96 additions and 0 deletions

View file

@ -183,6 +183,12 @@ def none_val(value):
return None
raise SettingsValidationError("This settings cannot be set in configuration file")
def str_val(value):
try:
str(value)
except Exception as e:
raise SettingsValidationError("Not able to convert value to string : " + str(e))
#
# Default validators registration
#
@ -197,6 +203,11 @@ SettingValidator.register_validator(
none_val,
'Validate None')
SettingValidator.register_validator(
'string',
str_val,
'Validate string values')
SettingValidator.register_validator(
'strip',
str.strip,
@ -294,5 +305,9 @@ LODEL2_CONF_SPECS = {
SettingValidator('list')),
'editormode': ( False,
SettingValidator('bool')),
},
'lodel2.datasources.*': {
'identifier': ( None,
SettingValidator('string'))
}
}