|
@@ -11,8 +11,8 @@ from . import lefactory
|
11
|
11
|
## @brief Main class for relations
|
12
|
12
|
class _LeRelation(lecrud._LeCrud):
|
13
|
13
|
|
14
|
|
- _lesup_name = None
|
15
|
|
- _lesub_name = None
|
|
14
|
+ _superior_field_name = None
|
|
15
|
+ _subordinate_field_name = None
|
16
|
16
|
## @brief Stores the list of fieldtypes that are common to all relations
|
17
|
17
|
_rel_fieldtypes = dict()
|
18
|
18
|
|
|
@@ -23,13 +23,13 @@ class _LeRelation(lecrud._LeCrud):
|
23
|
23
|
@classmethod
|
24
|
24
|
def sup_filter(self, leo):
|
25
|
25
|
if isinstance(leo, leobject._LeObject):
|
26
|
|
- return (self._lesup_name, '=', leo)
|
|
26
|
+ return (self._superior_field_name, '=', leo)
|
27
|
27
|
|
28
|
28
|
## @brief Forge a filter to match the superior
|
29
|
29
|
@classmethod
|
30
|
30
|
def sub_filter(self, leo):
|
31
|
31
|
if isinstance(leo, leobject._LeObject):
|
32
|
|
- return (self._lesub_name, '=', leo)
|
|
32
|
+ return (self._subordinate_field_name, '=', leo)
|
33
|
33
|
|
34
|
34
|
## @return a dict with field name as key and fieldtype instance as value
|
35
|
35
|
@classmethod
|
|
@@ -62,7 +62,7 @@ class _LeRelation(lecrud._LeCrud):
|
62
|
62
|
filters, rel_filters = super()._prepare_filters(filters_l)
|
63
|
63
|
res_filters = list()
|
64
|
64
|
for field, op, value in filters:
|
65
|
|
- if field in [cls._lesup_name, cls._lesub_name]:
|
|
65
|
+ if field in [cls._superior_field_name, cls._subordinate_field_name]:
|
66
|
66
|
if isinstance(value, str):
|
67
|
67
|
try:
|
68
|
68
|
value = int(value)
|
|
@@ -169,7 +169,7 @@ class _LeRel2Type(_LeRelation):
|
169
|
169
|
datas['nature'] = None
|
170
|
170
|
if cls == cls.name2class('LeRel2Type') and classname is None:
|
171
|
171
|
# autodetect the rel2type child class
|
172
|
|
- classname = relname(datas[self._lesup_name], datas[self._lesub_name])
|
|
172
|
+ classname = relname(datas[self._superior_field_name], datas[self._subordinate_field_name])
|
173
|
173
|
return super().insert(datas, classname)
|
174
|
174
|
|
175
|
175
|
## @brief Given a superior and a subordinate, returns the classname of the give rel2type
|