|
@@ -14,26 +14,35 @@ class EmFieldType(EmFieldType):
|
14
|
14
|
super(EmFieldType, self).__init__(**kwargs)
|
15
|
15
|
|
16
|
16
|
def check_data_value(self, value):
|
17
|
|
- return value is None or ( value in classtypes.EmNature.getall())
|
18
|
|
-
|
|
17
|
+ if value is None or ( value in classtypes.EmNature.getall()):
|
|
18
|
+ return value, None
|
|
19
|
+ else:
|
|
20
|
+ return None, ValueError("Unknown relation nature '%s'"%value)
|
|
21
|
+
|
|
22
|
+ ## @todo implements types checks
|
19
|
23
|
def check_data_consistency(self, lec, fname, datas):
|
20
|
24
|
#Checking given component
|
21
|
|
- if not isinstance(lec, lerelation.LeRelation):
|
22
|
|
- return ValueError("A field naturerelation has to be in a LeRelation object, but this one is in a '%s'"%lec.__name__)
|
|
25
|
+ #Replace with a test from _LeCrud
|
|
26
|
+ #if not isinstance(lec, lerelation._LeRelation):
|
|
27
|
+ # return ValueError("A field naturerelation has to be in a LeRelation object, but this one is in a '%s'"%lec.__name__)
|
23
|
28
|
nature = datas[fname]
|
24
|
29
|
lesup = datas['lesup']
|
25
|
30
|
lesub = datas['lesub']
|
26
|
31
|
if nature is None:
|
27
|
|
- if not isinstance(lec, lerelation.LeRel2Type):
|
28
|
|
- return ValueError("Only LeRel2Type are allowed to have NULL nature")
|
|
32
|
+ #if not isinstance(lec, lerelation.LeRel2Type):
|
|
33
|
+ #Replace with a test from _LeCrud
|
|
34
|
+ # return ValueError("Only LeRel2Type are allowed to have NULL nature")
|
|
35
|
+ pass
|
29
|
36
|
else:
|
30
|
|
- if not isinstance(lec, lerelation.LeHierarch):
|
31
|
|
- return ValueError("Only LeHierarch has not NULL nature")
|
|
37
|
+ #if not isinstance(lec, lerelation.LeHierarch):
|
|
38
|
+ #Replace with a test from _LeCrud
|
|
39
|
+ # return ValueError("Only LeHierarch has not NULL nature")
|
32
|
40
|
#Checking if nature <=> lesup & lesub classtypes
|
33
|
|
- if nature not in classtypes.EmClassType.natures(lesub._classtype):
|
34
|
|
- return ValueError("Invalid nature '%s' for %s"%(nature, lesub.__class__.__name__))
|
35
|
|
-
|
36
|
|
- if not lesup.is_root():
|
|
41
|
+ if not lesub.is_partial():
|
|
42
|
+ if nature not in classtypes.EmClassType.natures(lesub._classtype):
|
|
43
|
+ return ValueError("Invalid nature '%s' for %s"%(nature, lesub.__class__.__name__))
|
|
44
|
+
|
|
45
|
+ if not lesup.is_partial() and not lesup.is_root():
|
37
|
46
|
if nature not in classtypes.EmClassType.natures(lesup._classtype):
|
38
|
47
|
return ValueError("Invalid nature '%s' for %s"%(nature, lesup.__class__.__name__))
|
39
|
48
|
return True
|