[PATCH 1 of 6 seda] [entities] Don't attempt to clone the container relation

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 24 10:48:37 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490200323 -3600
#      Wed Mar 22 17:32:03 2017 +0100
# Node ID 3d222f60b28c00bd47987e8f9fc2f37739add17a
# Parent  b91f4a405baf2ba09744d97b84a67532bbef4293
[entities] Don't attempt to clone the container relation

The container relation is handled by hooks and must not be copied in any case.

diff --git a/cubicweb_seda/entities/__init__.py b/cubicweb_seda/entities/__init__.py
--- a/cubicweb_seda/entities/__init__.py
+++ b/cubicweb_seda/entities/__init__.py
@@ -156,18 +156,18 @@ class DirectLinkIContained(IContained):
 
 class SEDAArchiveTransferIClonableAdapter(IClonableAdapter):
     """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`."""
         if clone.seda_archive_unit and (
                 clone.seda_archive_unit[0].cw_etype == 'SEDAArchiveTransfer'
diff --git a/test/test_entities.py b/test/test_entities.py
--- a/test/test_entities.py
+++ b/test/test_entities.py
@@ -157,10 +157,17 @@ class ContainerTC(CubicWebTC):
             cnx.commit()
 
             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'
 
     def __init__(self, _cw):


More information about the saem-devel mailing list