[PATCH eac] Add some generic left/right properties on the various kind of relations

Sylvain Thénault sylvain.thenault at logilab.fr
Fri Mar 17 07:19:03 CET 2017



Le 16/03/2017 à 18:05, Philippe Pepiot a écrit :
> On 03/16/2017 03:34 PM, Sylvain Thenault wrote:
>> # HG changeset patch
>> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
>> # Date 1489674859 -3600
>> #      Thu Mar 16 15:34:19 2017 +0100
>> # Node ID eed500cfecb53e78aee95cd658db429ab3abdf2c
>> # Parent  11bb8cb5c00fca41e9b5d87bdca1a55d02abcfa7
>> Add some generic left/right properties on the various kind of relations
>>
>> so they can be accessed consistently.
>
> Why we need this ? Is this code reachable ?

This is used in the client cube saem_ref. For now, UI has not been
backported and still lies there, but it seems to me that those accessors
was still better located in the eac cube, but this is arguable.

>
>>
>> diff --git a/cubicweb_eac/entities.py b/cubicweb_eac/entities.py
>> --- a/cubicweb_eac/entities.py
>> +++ b/cubicweb_eac/entities.py
>> @@ -64,18 +64,53 @@ class AuthorityRecord(AnyEntity):
>>  class AgentKind(AnyEntity):
>>      __regid__ = 'AgentKind'
>>      fetch_attrs, cw_fetch_order = fetch_config(('name',))
>>
>>
>> -class ChronologicalRelation(AnyEntity):
>> -    __regid__ = 'ChronologicalRelation'
>> +class _Relation(AnyEntity):
>>
>>      def dc_description(self):
>>          if self.description:
>>              return self.description
>>
>>
>> +class ChronologicalRelation(_Relation):
>> +    __regid__ = 'ChronologicalRelation'
>> +
>> +    @property
>> +    def left(self):
>> +        return self.chronological_predecessor[0]
>> +
>> +    @property
>> +    def right(self):
>> +        return self.chronological_successor[0]
>> +
>> +
>> +class AssociationRelation(_Relation):
>> +    __regid__ = 'AssociationRelation'
>> +
>> +    @property
>> +    def left(self):
>> +        return self.association_from[0]
>> +
>> +    @property
>> +    def right(self):
>> +        return self.association_to[0]
>> +
>> +
>> +class HierarchicalRelation(_Relation):
>> +    __regid__ = 'HierarchicalRelation'
>> +
>> +    @property
>> +    def left(self):
>> +        return self.hierarchical_parent[0]
>> +
>> +    @property
>> +    def right(self):
>> +        return self.hierarchical_child[0]
>> +
>> +
>>  class EACResourceRelation(AnyEntity):
>>      __regid__ = 'EACResourceRelation'
>>      fetch_attrs, cw_fetch_order = fetch_config(('agent_role',
>> 'resource_role', 'description'))
>>
>>      @property
>>
>

-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the saem-devel mailing list