[PATCH 1 of 2 saem_ref V2] [compound] Skip Activity from compound graph definitions

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Mar 14 11:08:59 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1489485330 -3600
#      Tue Mar 14 10:55:30 2017 +0100
# Node ID cd42804332f89bf44ef924a48b254a2ec148dd55
# Parent  7f4f49b84a18866eab65c057d95ac98ae4322163
[compound] Skip Activity from compound graph definitions

it will cause problem to add activity logging support to SEDAArchiveTransfer
since it used a different IContained implementation than concept and authority
records, which is not supported by the compound cube.

diff --git a/cubicweb_saem_ref/entities/container.py b/cubicweb_saem_ref/entities/container.py
--- a/cubicweb_saem_ref/entities/container.py
+++ b/cubicweb_saem_ref/entities/container.py
@@ -13,13 +13,20 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-saem_ref "compound"-related functionalities."""
 
+from functools import partial
+
 from cubicweb_compound import structure_def
 from cubicweb_compound.entities import IContainer, IContained
 
+# don't put Activity in a compound graph, it causes problem since it belongs to both
+# SEDAArchiveTransfer tree and to concept/authority record tree, which don't have the same
+# IContained implementation.
+structure_def = partial(structure_def, skipetypes=('Activity',))
+
 
 def authority_record_container_def(schema):
     """Define container for AuthorityRecord"""
     return structure_def(schema, 'AuthorityRecord').items()
 
diff --git a/test/unittest_entities_container.py b/test/unittest_entities_container.py
--- a/test/unittest_entities_container.py
+++ b/test/unittest_entities_container.py
@@ -32,12 +32,11 @@ class ContainerTC(CubicWebTC):
     def test_authorityrecord_container(self):
         # line below should be copied from entities.container.registration_callback
         container_def = container.authority_record_container_def(self.schema)
         container_def = dict(sort_container(container_def))
         self.assertEqual(container_def,
-                         {'Activity': [('generated', 'subject'), ('used', 'subject')],
-                          'AgentFunction': [('function_agent', 'subject')],
+                         {'AgentFunction': [('function_agent', 'subject')],
                           'AgentPlace': [('place_agent', 'subject')],
                           'Citation': [('has_citation', 'object')],
                           'EACOtherRecordId': [('eac_other_record_id_of', 'subject')],
                           'EACResourceRelation': [('resource_relation_agent', 'subject')],
                           'EACSource': [('source_agent', 'subject')],
@@ -56,23 +55,21 @@ class ContainerTC(CubicWebTC):
     def test_scheme_container(self):
         # line below should be copied from entities.container.registration_callback
         container_def = container.scheme_container_def(self.schema)
         container_def = dict(sort_container(container_def))
         self.assertEqual(container_def,
-                         {'Activity': [('generated', 'subject'), ('used', 'subject')],
-                          'Concept': [('in_scheme', 'subject')]})
+                         {'Concept': [('in_scheme', 'subject')]})
         entity = self.vreg['etypes'].etype_class('ConceptScheme')(self)
         self.assertIsNotNone(entity.cw_adapt_to('IContainer'))
         self.assertIsNone(entity.cw_adapt_to('IContained'))
 
     def test_concept_container(self):
         # line below should be copied from entities.container.registration_callback
         container_def = container.concept_container_def(self.schema)
         container_def = dict(sort_container(container_def))
         self.assertEqual(container_def,
-                         {'Activity': [('generated', 'subject'), ('used', 'subject')],
-                          'Label': [('label_of', 'subject')]})
+                         {'Label': [('label_of', 'subject')]})
         entity = self.vreg['etypes'].etype_class('Concept')(self)
         self.assertIsNotNone(entity.cw_adapt_to('IContainer'))
         # Concept is both container and contained :
         self.assertIsNotNone(entity.cw_adapt_to('IContained'))
 


More information about the saem-devel mailing list