[PATCH 1 of 2 eac] Make relations to "relationship" entity type composite on AuthorityRecord

Denis Laxalde denis.laxalde at logilab.fr
Thu Oct 18 14:46:08 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1539865550 -7200
#      Thu Oct 18 14:25:50 2018 +0200
# Node ID a586045910695ec224c055b8cbc115de624e8018
# Parent  c05e9eb06e5faaa0558bb9895eaae5e8e0b6547d
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r a58604591069
Make relations to "relationship" entity type composite on AuthorityRecord

Previously, it was not possible to delete an AuthorityRecord with any of
the relationships defined as inheriting from '_agent_relation' set. We'd
get an error like:

  ValidationError: <eid> (association_to-subject): at least one relation
    association_to is required on AssociationRelation (<eid>)

This is because the relation, e.g. association_to, was missing a
composite='object' flag in its definition which trigger relation
deletion when the composite (i.e. the AuthorityRecord entity) is
deleted.

Fixing this, thus making AuthorityRecord deletion possible in that case.

Test update concerns the compound graph structure in which these
relations now show up.

diff --git a/cubicweb_eac/migration/0.8.0_Any.py b/cubicweb_eac/migration/0.8.0_Any.py
new file mode 100644
--- /dev/null
+++ b/cubicweb_eac/migration/0.8.0_Any.py
@@ -0,0 +1,9 @@
+for rtype in (
+    'association_from',
+    'association_to',
+    'chronological_predecessor',
+    'chronological_successor',
+    'hierarchical_parent',
+    'hierarchical_child',
+):
+    sync_schema_props_perms(rtype)
diff --git a/cubicweb_eac/schema.py b/cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py
+++ b/cubicweb_eac/schema.py
@@ -185,6 +185,7 @@ class _agent_relation(RelationDefinition
     object = ('AuthorityRecord', 'ExternalUri')
     cardinality = '1*'
     inlined = True
+    composite = 'object'
 
 
 @xml_wrap
diff --git a/test/test_schema.py b/test/test_schema.py
--- a/test/test_schema.py
+++ b/test/test_schema.py
@@ -99,6 +99,14 @@ class AuthorityRecordGraphTC(CubicWebTC)
         expected = {
             'AgentFunction': {('function_agent', 'subject'): set(['AuthorityRecord'])},
             'AgentPlace': {('place_agent', 'subject'): set(['AuthorityRecord'])},
+            'AssociationRelation': {
+                ('association_from', 'subject'): set(['AuthorityRecord']),
+                ('association_to', 'subject'): set(['AuthorityRecord']),
+            },
+            'ChronologicalRelation': {
+                ('chronological_predecessor', 'subject'): set(['AuthorityRecord']),
+                ('chronological_successor', 'subject'): set(['AuthorityRecord']),
+            },
             'Citation': {('has_citation', 'object'): set([
                 'GeneralContext', 'Mandate', 'Occupation', 'AgentFunction',
                 'AgentPlace', 'History', 'LegalStatus',
@@ -109,6 +117,10 @@ class AuthorityRecordGraphTC(CubicWebTC)
                                     set(['AuthorityRecord'])},
             'EACSource': {('source_agent', 'subject'): set(['AuthorityRecord'])},
             'GeneralContext': {('general_context_of', 'subject'): set(['AuthorityRecord'])},
+            'HierarchicalRelation': {
+                ('hierarchical_child', 'subject'): set(['AuthorityRecord']),
+                ('hierarchical_parent', 'subject'): set(['AuthorityRecord']),
+            },
             'History': {('history_agent', 'subject'): set(['AuthorityRecord'])},
             'LegalStatus': {('legal_status_agent', 'subject'): set(['AuthorityRecord'])},
             'Mandate': {('mandate_agent', 'subject'): set(['AuthorityRecord'])},



More information about the saem-devel mailing list