|
|
|
|
257
|
# @param **kwargs : other arguments
|
257
|
# @param **kwargs : other arguments
|
258
|
def __init__(self, allowed_classes=None, back_reference=None, internal=False, **kwargs):
|
258
|
def __init__(self, allowed_classes=None, back_reference=None, internal=False, **kwargs):
|
259
|
self.__allowed_classes = set() if allowed_classes is None else set(allowed_classes)
|
259
|
self.__allowed_classes = set() if allowed_classes is None else set(allowed_classes)
|
260
|
- self.allowed_classes = list() if allowed_classes is None else allowed_classes
|
|
|
|
|
260
|
+ self.allowed_classes = list() if allowed_classes is None else allowed_classes # For now usefull to jinja 2
|
261
|
if back_reference is not None:
|
261
|
if back_reference is not None:
|
262
|
if len(back_reference) != 2:
|
262
|
if len(back_reference) != 2:
|
263
|
raise ValueError("A tuple (classname, fieldname) expected but got '%s'" % back_reference)
|
263
|
raise ValueError("A tuple (classname, fieldname) expected but got '%s'" % back_reference)
|
|
|
|
|
318
|
#@param datas dict : dict storing fields values
|
318
|
#@param datas dict : dict storing fields values
|
319
|
#@return an Exception instance if fails else True
|
319
|
#@return an Exception instance if fails else True
|
320
|
#@todo check for performance issue and check logics
|
320
|
#@todo check for performance issue and check logics
|
321
|
- #@todo Implements consistency checking on value : Check that the given value
|
|
|
322
|
- #points onto an allowed class
|
|
|
323
|
#@warning composed uid capabilities broken here
|
321
|
#@warning composed uid capabilities broken here
|
324
|
def check_data_consistency(self, emcomponent, fname, datas):
|
322
|
def check_data_consistency(self, emcomponent, fname, datas):
|
325
|
rep = super().check_data_consistency(emcomponent, fname, datas)
|
323
|
rep = super().check_data_consistency(emcomponent, fname, datas)
|
|
|
|
|
329
|
return True
|
327
|
return True
|
330
|
# !! Reimplement instance fetching in construct data !!
|
328
|
# !! Reimplement instance fetching in construct data !!
|
331
|
target_class = self.back_reference[0]
|
329
|
target_class = self.back_reference[0]
|
|
|
330
|
+ if target_class not in self.__allowed_class:
|
|
|
331
|
+ logger.warning('Class of the back_reference given is not an allowed class')
|
|
|
332
|
+ return False
|
332
|
target_uidfield = target_class.uid_fieldname()[0] #multi uid broken here
|
333
|
target_uidfield = target_class.uid_fieldname()[0] #multi uid broken here
|
333
|
value = datas[fname]
|
334
|
value = datas[fname]
|
334
|
obj = target_class.get([(target_uidfield, '=', value)])
|
335
|
obj = target_class.get([(target_uidfield, '=', value)])
|
|
|
|
|
359
|
#@return value
|
360
|
#@return value
|
360
|
def _check_data_value(self, value):
|
361
|
def _check_data_value(self, value):
|
361
|
value = super()._check_data_value(value)
|
362
|
value = super()._check_data_value(value)
|
362
|
- logger.warning("A vérifier..provisoire pour les tests")
|
|
|
363
|
- #if (expt is None and (len(val)>1)):
|
|
|
364
|
- # raise FieldValidationError("List or string expected for a set field")
|
|
|
365
|
return value
|
363
|
return value
|
366
|
|
364
|
|
367
|
##@brief Utility method designed to fetch referenced objects
|
365
|
##@brief Utility method designed to fetch referenced objects
|