Przeglądaj źródła

Added list error when check MultipleRef value

m.orban 8 lat temu
rodzic
commit
120a8028d8
2 zmienionych plików z 12 dodań i 13 usunięć
  1. 12
    12
      lodel/leapi/datahandlers/base_classes.py
  2. 0
    1
      lodel/leapi/query.py

+ 12
- 12
lodel/leapi/datahandlers/base_classes.py Wyświetl plik

@@ -85,17 +85,14 @@ class DataHandler(object):
85 85
     def _check_data_value(self, value):
86 86
         if value is None:
87 87
             if not self.nullable:
88
-                raise LodelExceptions("None value is forbidden")
89
-            raise DataNoneValid("None with a nullable. GOTO CHECK")
88
+                raise LodelExceptions("None value is forbidden for this data field")
89
+            raise DataNoneValid("None with a nullable. This exeption is allowed")
90 90
         return value
91 91
 
92 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
+    ##@brief calls the data_field (defined in derived class) _check_data_value() method
94
+    #@param value *
95
+    #@return tuple (value|None, None|error) value can be cast if NoneError
99 96
     def check_data_value(self, value):
100 97
         try:
101 98
             value = self._check_data_value(value)
@@ -353,7 +350,7 @@ class SingleRef(Reference):
353 350
         super().__init__(allowed_classes = allowed_classes)
354 351
  
355 352
     ##@brief Check and cast value in appropriate type
356
-    #@param value *
353
+    #@param value: *
357 354
     #@throw FieldValidationError if value is unappropriate or can not be cast 
358 355
     #@return value
359 356
     def _check_data_value(self, value):
@@ -389,10 +386,13 @@ class MultipleRef(Reference):
389 386
         if self.max_item is not None:
390 387
             if self.max_item < len(value):
391 388
                 raise FieldValidationError("Too many items")
392
-        ref_list = []
393
-        #Checked reference value one by one . 
389
+        error_list = []
394 390
         for v in value.items():
395
-            ref_list.append(super()._check_data_value(v))
391
+            val, error = super()._check_data_value(v)
392
+            if error:
393
+                error_list.append(val, error)
394
+        if len(error_list) >0:
395
+            raise FieldValidationError("MultipleRef have for error :", error_list)
396 396
         return value
397 397
 
398 398
     def construct_data(self, emcomponent, fname, datas, cur_value):

+ 0
- 1
lodel/leapi/query.py Wyświetl plik

@@ -335,7 +335,6 @@ field to use for the relational filter"
335 335
                 else:
336 336
                     rel_filters.append((ret, operator, value))
337 337
             else:
338
-                # Casting value given datahandler
339 338
                 value_orig = value
340 339
                 value, error = field_datahandler.check_data_value(value)
341 340
                 if isinstance(error, Exception):

Loading…
Anuluj
Zapisz