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:
parent
bf879a833c
commit
6fb04a69fb
3 changed files with 96 additions and 0 deletions
|
|
@ -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'))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue