|
@@ -31,7 +31,6 @@ class DataHandler(object):
|
31
|
31
|
##@brief List fields that will be exposed to the construct_data_method
|
32
|
32
|
_construct_datas_deps = []
|
33
|
33
|
|
34
|
|
- directly_editable = True
|
35
|
34
|
##@brief constructor
|
36
|
35
|
# @param internal False | str : define whether or not a field is internal
|
37
|
36
|
# @param immutable bool : indicates if the fieldtype has to be defined in child classes of LeObject or if it is
|
|
@@ -251,15 +250,11 @@ class Reference(DataHandler):
|
251
|
250
|
# @param internal bool : if False, the field is not internal
|
252
|
251
|
# @param **kwargs : other arguments
|
253
|
252
|
def __init__(self, allowed_classes = None, back_reference = None, internal=False, **kwargs):
|
|
253
|
+ ##@brief set of allowed LeObject child classes
|
254
|
254
|
self.__allowed_classes = set() if allowed_classes is None else set(allowed_classes)
|
255
|
|
- self.allowed_classes = list() if allowed_classes is None else allowed_classes
|
256
|
|
-
|
257
|
|
- if back_reference is not None:
|
258
|
|
- if len(back_reference) != 2:
|
259
|
|
- raise ValueError("A tuple (classname, fieldname) expected but got '%s'" % back_reference)
|
260
|
|
- #if not issubclass(lodel.leapi.leobject.LeObject, back_reference[0]) or not isinstance(back_reference[1], str):
|
261
|
|
- # raise TypeError("Back reference was expected to be a tuple(<class LeObject>, str) but got : (%s, %s)" % (back_reference[0], back_reference[1]))
|
262
|
|
- self.__back_reference = back_reference
|
|
255
|
+ ##@brief Stores back references informations
|
|
256
|
+ self.__back_reference = None
|
|
257
|
+ self.__set_back_reference(back_reference)
|
263
|
258
|
super().__init__(internal=internal, **kwargs)
|
264
|
259
|
|
265
|
260
|
@property
|
|
@@ -271,7 +266,13 @@ class Reference(DataHandler):
|
271
|
266
|
return copy.copy(self.__allowed_classes)
|
272
|
267
|
|
273
|
268
|
##@brief Set the back reference for this field.
|
274
|
|
- def _set_back_reference(self, back_reference):
|
|
269
|
+ def __set_back_reference(self, back_reference):
|
|
270
|
+ if back_reference is None:
|
|
271
|
+ return
|
|
272
|
+ if len(back_reference) != 2:
|
|
273
|
+ raise LodelDataHandlerException("A tuple(LeObjectChild, fieldname) \
|
|
274
|
+expected but got '%s'" % back_reference)
|
|
275
|
+
|
275
|
276
|
self.__back_reference = back_reference
|
276
|
277
|
|
277
|
278
|
##@brief Check value
|