|
@@ -77,6 +77,11 @@ class DataHandler(object):
|
77
|
77
|
def is_internal(self):
|
78
|
78
|
return self.internal is not False
|
79
|
79
|
|
|
80
|
+ ##brief check if a value can be nullable
|
|
81
|
+ #@param value *
|
|
82
|
+ #@throw DataNoneValid if value is None and nullable. LodelExceptions if not nullable
|
|
83
|
+ #@return value (if not None)
|
|
84
|
+ # @return value
|
80
|
85
|
def _check_data_value(self, value):
|
81
|
86
|
if value is None:
|
82
|
87
|
if not self.nullable:
|
|
@@ -84,12 +89,13 @@ class DataHandler(object):
|
84
|
89
|
raise DataNoneValid("None with a nullable. GOTO CHECK")
|
85
|
90
|
return value
|
86
|
91
|
|
87
|
|
-#
|
88
|
|
-# ##@brief calls the data_field defined _check_data_value() method
|
89
|
|
-# #@ingroup lodel2_dh_checks
|
90
|
|
-# #@warning DO NOT REIMPLEMENT THIS METHOD IN A CUSTOM DATAHANDLER (see
|
91
|
|
-# #@ref _construct_data() and @ref lodel2_dh_check_impl )
|
92
|
|
-# #@return tuple (value, error|None)
|
|
92
|
+
|
|
93
|
+ ##@brief calls the data_field defined _check_data_value() method
|
|
94
|
+ #@ingroup lodel2_dh_checks
|
|
95
|
+ #@warning DO NOT REIMPLEMENT THIS METHOD IN A CUSTOM DATAHANDLER (see
|
|
96
|
+ #@ref _construct_data() and @ref lodel2_dh_check_impl)
|
|
97
|
+
|
|
98
|
+ #@return tuple (value, Exceptions)
|
93
|
99
|
def check_data_value(self, value):
|
94
|
100
|
try:
|
95
|
101
|
value = self._check_data_value(value)
|
|
@@ -98,7 +104,7 @@ class DataHandler(object):
|
98
|
104
|
except (LodelExceptions, FieldValidationError) as expt:
|
99
|
105
|
return None, expt
|
100
|
106
|
return value, None
|
101
|
|
-#
|
|
107
|
+
|
102
|
108
|
##@brief checks if this class can override the given data handler
|
103
|
109
|
# @param data_handler DataHandler
|
104
|
110
|
# @return bool
|
|
@@ -290,16 +296,17 @@ class Reference(DataHandler):
|
290
|
296
|
def _set_back_reference(self, back_reference):
|
291
|
297
|
self.__back_reference = back_reference
|
292
|
298
|
|
293
|
|
- ##@brief Check value
|
|
299
|
+ ##@brief Check and cast value in appropriate type
|
294
|
300
|
#@param value *
|
295
|
|
- #@return tuple(value, exception)
|
296
|
|
- #@todo implement the check when we have LeObject to check value
|
|
301
|
+ #@throw FieldValidationError if value is an appropriate type
|
|
302
|
+ #@return value
|
|
303
|
+ #@todo implement the check when we have LeObject uid check value
|
297
|
304
|
def _check_data_value(self, value):
|
298
|
305
|
value= super()._check_data_value(value)
|
299
|
306
|
elt = self.__allowed_classes[0]
|
300
|
307
|
uid = elt.uid_fieldname()[0]# TODO multiple uid is broken
|
301
|
308
|
if (expt is None and not (isinstance(value, LeObject)) or (value is uid)):
|
302
|
|
- raise FieldValidationError("LeObject instance or id exxpected for a reference field")
|
|
309
|
+ raise FieldValidationError("LeObject instance or id expected for a reference field")
|
303
|
310
|
return value
|
304
|
311
|
|
305
|
312
|
def construct_data(self, emcomponent, fname, datas, cur_value):
|
|
@@ -345,6 +352,10 @@ class SingleRef(Reference):
|
345
|
352
|
def __init__(self, allowed_classes = None, **kwargs):
|
346
|
353
|
super().__init__(allowed_classes = allowed_classes)
|
347
|
354
|
|
|
355
|
+ ##@brief Check and cast value in appropriate type
|
|
356
|
+ #@param value *
|
|
357
|
+ #@throw FieldValidationError if value is unappropriate or can not be cast
|
|
358
|
+ #@return value
|
348
|
359
|
def _check_data_value(self, value):
|
349
|
360
|
value = super()._check_data_value(value)
|
350
|
361
|
if (expt is None and (len(val)>1)):
|
|
@@ -366,7 +377,11 @@ class MultipleRef(Reference):
|
366
|
377
|
self.max_item = max_item
|
367
|
378
|
super().__init__(**kwargs)
|
368
|
379
|
|
369
|
|
- #@TODO checkig one by one and put error in a list
|
|
380
|
+ ##@brief Check and cast value in appropriate type
|
|
381
|
+ #@param value *
|
|
382
|
+ #@throw FieldValidationError if value is unappropriate or can not be cast
|
|
383
|
+ #@return value
|
|
384
|
+ #@TODO checkig one by one and put error in a list
|
370
|
385
|
def _check_data_value(self, value):
|
371
|
386
|
value = super()._check_data_value(value)
|
372
|
387
|
if not hasattr(value, '__iter__'):
|