[entities] Don't attempt to clone the container relation
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 22 Mar 2017 17:32:03 +0100
changeset 2520 3d222f60b28c
parent 2519 b91f4a405baf
child 2521 97ae1cc7a9e7
[entities] Don't attempt to clone the container relation The container relation is handled by hooks and must not be copied in any case.
cubicweb_seda/entities/__init__.py
test/test_entities.py
--- a/cubicweb_seda/entities/__init__.py	Tue Mar 21 14:37:35 2017 +0100
+++ b/cubicweb_seda/entities/__init__.py	Wed Mar 22 17:32:03 2017 +0100
@@ -158,14 +158,14 @@
     """Cloning adapter for SEDA profiles."""
     __select__ = is_instance('SEDAArchiveTransfer')
     rtype = 'clone_of'
-    skiprtypes = ()
+    skiprtypes = ('container',)
 
 
 class SEDAArchiveUnitIClonableAdapter(IClonableAdapter):
     """Cloning adapter for SEDA components."""
     __select__ = is_instance('SEDAArchiveUnit')
     rtype = 'clone_of'
-    skiprtypes = ()
+    skiprtypes = ('container',)
 
     def clone_into(self, clone):
         """Recursivily clone the container graph of this entity into `clone`."""
--- a/test/test_entities.py	Tue Mar 21 14:37:35 2017 +0100
+++ b/test/test_entities.py	Wed Mar 22 17:32:03 2017 +0100
@@ -159,6 +159,13 @@
             cloned2.cw_clear_all_caches()
             self.assertEqual(len(cloned2.seda_alt_archive_unit_archive_unit_ref_id), 1)
 
+            unit_alt.cw_clear_all_caches()
+            self.assertEqual(unit_alt.container[0].eid, unit.eid)
+            self.assertEqual(cloned.seda_alt_archive_unit_archive_unit_ref_id[0].container[0].eid,
+                             cloned.eid)
+            self.assertEqual(cloned2.seda_alt_archive_unit_archive_unit_ref_id[0].container[0].eid,
+                             cloned2.eid)
+
 
 class FakeEntity(object):
     cw_etype = 'Whatever'