[PATCH 2 of 2 eac] [entities] allow controlling export of recordId and otherRecordId

Philippe Pepiot philippe.pepiot at logilab.fr
Fri Feb 24 17:55:37 CET 2017


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1487955070 -3600
#      Fri Feb 24 17:51:10 2017 +0100
# Node ID 8eea971119c48ad944a366f08ed675c551fe3288
# Parent  a7a2ad4e5cf2a4a266897b04defb9dbc90467844
# Available At https://hg.logilab.org/review/cubes/eac
#              hg pull https://hg.logilab.org/review/cubes/eac -r 8eea971119c4
# Tested at: https://jenkins.logilab.org/job/cubicweb-eac/58/
[entities] allow controlling export of recordId and otherRecordId

This allow to control what will be written in <recordId> and <otherRecordId> by
inheriting AuthorityRecordEACAdapter.

Related to extranet #12572781

diff --git a/cubicweb_eac/entities.py b/cubicweb_eac/entities.py
--- a/cubicweb_eac/entities.py
+++ b/cubicweb_eac/entities.py
@@ -278,6 +278,16 @@ class AuthorityRecordEACAdapter(Abstract
             name = text_type(self.entity.eid)
         return u'EAC_{0}.xml'.format(name)
 
+    @property
+    def record_id(self):
+        # likely inherited in other cubes
+        return self.entity.record_id
+
+    @property
+    def other_record_ids(self):
+        # likely inherited in other cubes
+        return self.entity.other_record_ids
+
     def dump(self):
         """Return an XML string representing the given agent using the EAC-CPF schema."""
         # Keep related activities since they are used multiple times
@@ -295,11 +305,11 @@ class AuthorityRecordEACAdapter(Abstract
 
     def control_element(self, eac_cpf_elt):
         control_elt = self.element('control', parent=eac_cpf_elt)
-        record_id = self.entity.record_id
+        record_id = self.record_id
         if record_id is None:
             record_id = text_type(self.entity.eid)
         self.element('recordId', parent=control_elt, text=record_id)
-        for local_type, value in self.entity.other_record_ids:
+        for local_type, value in self.other_record_ids:
             attrs = {}
             if local_type is not None:
                 attrs['localType'] = local_type



More information about the saem-devel mailing list