|
@@ -11,7 +11,7 @@
|
11
|
11
|
# @note LeObject will be generated by leapi.lefactory.LeFactory
|
12
|
12
|
|
13
|
13
|
import leapi
|
14
|
|
-from leapi.lecrud import _LeCrud
|
|
14
|
+from leapi.lecrud import _LeCrud, LeApiDataCheckError
|
15
|
15
|
from leapi.leclass import _LeClass
|
16
|
16
|
from leapi.leobject import LeObjectError
|
17
|
17
|
|
|
@@ -35,7 +35,9 @@ class _LeType(_LeClass):
|
35
|
35
|
if self._leclass is None:
|
36
|
36
|
raise NotImplementedError("Abstract class")
|
37
|
37
|
|
38
|
|
- self.lodel_id = lodel_id
|
|
38
|
+ self.lodel_id, err = self._uid_fieldtype['lodel_id'].check_data_value(lodel_id)
|
|
39
|
+ if isinstance(err, Exception):
|
|
40
|
+ raise err
|
39
|
41
|
|
40
|
42
|
if 'type_id' in kwargs:
|
41
|
43
|
if self.__class__._type_id != int(kwargs['type_id']):
|
|
@@ -45,10 +47,18 @@ class _LeType(_LeClass):
|
45
|
47
|
raise RuntimeError("Trying to instanciate a %s with a clas_id that is not correct"%self.__class__.__name__)
|
46
|
48
|
|
47
|
49
|
## Populate the object from the datas received in kwargs
|
|
50
|
+ err_l = list()
|
48
|
51
|
for name, value in kwargs.items():
|
49
|
52
|
if name not in self._fields:
|
50
|
53
|
raise AttributeError("No such field '%s' for %s"%(name, self.__class__.__name__))
|
51
|
|
- setattr(self, name, value)
|
|
54
|
+
|
|
55
|
+ cvalue, err = self.fieldtypes()[name].check_data_value(value)
|
|
56
|
+ if isinstance(err, Exception):
|
|
57
|
+ err_l.append(err)
|
|
58
|
+ else:
|
|
59
|
+ setattr(self, name, value)
|
|
60
|
+ if len(err_l) > 0:
|
|
61
|
+ raise LeApiDataCheckError("Invalid arguments given to constructor", err_l)
|
52
|
62
|
|
53
|
63
|
@classmethod
|
54
|
64
|
def fieldlist(cls):
|