Browse Source

Bugfix in Reference abstract DataHandler class

refs #131
Yann Weber 8 years ago
parent
commit
ae9829d31d
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      lodel/leapi/datahandlers/base_classes.py

+ 6
- 4
lodel/leapi/datahandlers/base_classes.py View File

@@ -296,10 +296,12 @@ class Reference(DataHandler):
296 296
     def _check_data_value(self, value):
297 297
         from lodel.leapi.leobject import LeObject
298 298
         value = super()._check_data_value(value)
299
-        elt = list(self.__allowed_classes)[0]
300
-        uid = elt.uid_fieldname()[0]# TODO multiple uid is broken
301
-        if not (hasattr(value, '__class__') and issubclass(value.__class__, LeObject)) or (value is uid):
302
-            raise FieldValidationError("LeObject instance or id expected for a reference field")
299
+        if not (hasattr(value, '__class__') and
300
+                issubclass(value.__class__, LeObject)):
301
+            rcls = list(self.__allowed_classes)[0]
302
+            uidname = rcls.uid_fieldname()[0]# TODO multiple uid is broken
303
+            uiddh = rcls.data_handler(uidname)
304
+            uiddh._check_data_value(value)
303 305
         return value
304 306
 
305 307
     def construct_data(self, emcomponent, fname, datas, cur_value):

Loading…
Cancel
Save