[PATCH 2 of 2 compound] Add follow_relations to cw_skip_copy_for

Sylvain Thénault sylvain.thenault at logilab.fr
Thu Dec 14 07:58:12 CET 2017


this series breaks CI, sending a V2.


On 12/12/2017 18:16, Sylvain Thenault wrote:
> # HG changeset patch
> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
> # Date 1513098573 -3600
> #      Tue Dec 12 18:09:33 2017 +0100
> # Node ID 2d8973957d74a4da101c441e7e7655cd92ee6ad2
> # Parent  968fa97d5499ab720b2b49e34779e11230b92754
> Add follow_relations to cw_skip_copy_for
>
> When one add some non-composite relation to be followed, it should be
> automatically added to cw_skip_copy_for else it will be both deep copied and
> swallow copied, as demonstrated by the amended test.
>
> diff --git a/cubicweb_compound/entities.py b/cubicweb_compound/entities.py
> --- a/cubicweb_compound/entities.py
> +++ b/cubicweb_compound/entities.py
> @@ -231,10 +231,13 @@ class IClonableAdapter(EntityAdapter):
>      def skip_swallow_copy_for(self):
>          return set(chain(
>              # turn skiprtypes into a list suitable for Entity.cw_skip_copy_for
>              ((rtype, 'subject') for rtype in self.skiprtypes),
>              ((rtype, 'object') for rtype in self.skiprtypes),
> +            # also, relations that should be considered for cloning
> +            # shouldn't be also swallow copied
> +            self.follow_relations,
>          ))
>  
>  
>  def registration_callback(vreg):
>      vreg.register_all(globals().values(), __name__)
> diff --git a/test/test_compound.py b/test/test_compound.py
> --- a/test/test_compound.py
> +++ b/test/test_compound.py
> @@ -350,10 +350,13 @@ class CloneTC(CubicWebTC):
>                  ' NOT G identity OG',
>                  {'og': group.eid})
>              self.assertEqual(len(rset), 1)
>              self.assertEqual(clone.reverse_member[0].eid, rset[0][0])
>  
> +            group = cnx.entity_from_eid(group.eid)
> +            self.assertEqual(len(group.member), 1)
> +
>      def test_clone_skiprtypes(self):
>          with self.admin_access.repo_cnx() as cnx:
>              bob = cnx.create_entity('Agent', name=u'bob')
>              cnx.create_entity('Group', member=bob)
>              cnx.commit()
>

-- 
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