for a multi mandatory, allow [] with allow_empty_list attribut

This commit is contained in:
2015-04-20 14:49:43 +02:00
parent 072246a203
commit 487b99b32c
6 changed files with 73 additions and 14 deletions

View File

@ -32,7 +32,8 @@ class StorageBase(object):
'_multi',
'_extra',
'_warnings_only',
#valeur
'_allow_empty_list',
#value
'_default',
'_default_multi',
#calcul
@ -41,10 +42,7 @@ class StorageBase(object):
'_properties',
'_calc_properties',
'_val_call',
#'_validator',
#'_validator_params',
#'_callback',
#'_callback_params',
#
'_consistencies',
'_master_slaves',
'_choice_values',
@ -62,7 +60,7 @@ class StorageBase(object):
)
def __init__(self, name, multi, warnings_only, doc, extra, calc_properties,
requires, properties, opt=undefined):
requires, properties, allow_empty_list, opt=undefined):
self._name = name
if doc is not undefined:
self._informations = {'doc': doc}
@ -81,6 +79,8 @@ class StorageBase(object):
self._properties = properties
if opt is not undefined:
self._opt = opt
if allow_empty_list is not False:
self._allow_empty_list = allow_empty_list
def _set_default_values(self, default, default_multi):
if ((self.impl_is_multi() and default != tuple()) or
@ -298,6 +298,13 @@ class StorageBase(object):
_multi = 1
return _multi == 2
def impl_allow_empty_list(self):
try:
return self._allow_empty_list
except AttributeError:
return False
def _get_extra(self, key):
extra = self._extra
if isinstance(extra, tuple):
@ -308,7 +315,7 @@ class StorageBase(object):
def _is_warnings_only(self):
try:
return self._warnings_only
except:
except AttributeError:
return False
def impl_getdefault(self):