1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-04-27 02:40:57 +02:00

Bugfixes due to properties name changes in LeRelation

This commit is contained in:
Yann 2016-01-07 13:52:13 +01:00
commit 222f10282d
5 changed files with 13 additions and 13 deletions

View file

@ -56,8 +56,8 @@ class EmFieldType(GenericFieldType):
def check_sup_consistency(self, lec, fname, datas):
if lec.implements_lerel2type():
# Checking consistency for a rel2type relation
lesup = datas[lec._lesup_name]
lesub = datas[lec._lesub_name]
lesup = datas[lec._superior_field_name]
lesub = datas[lec._subordinate_field_name]
if lesub.__class__ not in lesup._linked_types:
return FieldTypeError("Rel2type not authorized between %s and %s"%(lesup, lesub))
pass

View file

@ -26,8 +26,8 @@ class EmFieldType(EmFieldType):
#if not isinstance(lec, lerelation._LeRelation):
# return ValueError("A field naturerelation has to be in a LeRelation object, but this one is in a '%s'"%lec.__name__)
nature = datas[fname]
lesup = datas[lec._lesup_name]
lesub = datas[lec._lesub_name]
lesup = datas[lec._superior_field_name]
lesub = datas[lec._subordinate_field_name]
if nature is None:
#if not isinstance(lec, lerelation.LeRel2Type):
#Replace with a test from _LeCrud

View file

@ -173,7 +173,7 @@ class _LeCrud(object):
# @param cls Class: a Class or instanciated object
@classmethod
def implements_lerelation(cls):
return hasattr(cls, '_lesup_name')
return hasattr(cls, '_superior_field_name')
## @return maybe Bool: True if cls implements LeRel2Type
# @param cls Class: a Class or instanciated object

View file

@ -244,8 +244,8 @@ class LeObject(LeCrud, leapi.leobject._LeObject):
class LeRelation(LeCrud, leapi.lerelation._LeRelation):
_uid_fieldtype = {lerel_uid_fieldtype}
_rel_fieldtypes = {lerel_fieldtypes}
_superior_fieldname = {lesup_name}
_subordinate_fieldname = {lesub_name}
_superior_field_name = {lesup_name}
_subordinate_field_name = {lesub_name}
class LeHierarch(LeRelation, leapi.lerelation._LeHierarch):
pass

View file

@ -11,8 +11,8 @@ from . import lefactory
## @brief Main class for relations
class _LeRelation(lecrud._LeCrud):
_lesup_name = None
_lesub_name = None
_superior_field_name = None
_subordinate_field_name = None
## @brief Stores the list of fieldtypes that are common to all relations
_rel_fieldtypes = dict()
@ -23,13 +23,13 @@ class _LeRelation(lecrud._LeCrud):
@classmethod
def sup_filter(self, leo):
if isinstance(leo, leobject._LeObject):
return (self._lesup_name, '=', leo)
return (self._superior_field_name, '=', leo)
## @brief Forge a filter to match the superior
@classmethod
def sub_filter(self, leo):
if isinstance(leo, leobject._LeObject):
return (self._lesub_name, '=', leo)
return (self._subordinate_field_name, '=', leo)
## @return a dict with field name as key and fieldtype instance as value
@classmethod
@ -62,7 +62,7 @@ class _LeRelation(lecrud._LeCrud):
filters, rel_filters = super()._prepare_filters(filters_l)
res_filters = list()
for field, op, value in filters:
if field in [cls._lesup_name, cls._lesub_name]:
if field in [cls._superior_field_name, cls._subordinate_field_name]:
if isinstance(value, str):
try:
value = int(value)
@ -169,7 +169,7 @@ class _LeRel2Type(_LeRelation):
datas['nature'] = None
if cls == cls.name2class('LeRel2Type') and classname is None:
# autodetect the rel2type child class
classname = relname(datas[self._lesup_name], datas[self._lesub_name])
classname = relname(datas[self._superior_field_name], datas[self._subordinate_field_name])
return super().insert(datas, classname)
## @brief Given a superior and a subordinate, returns the classname of the give rel2type