[PATCH 08 of 16 eac] [py3] Add a key function to sort other record ids

Denis Laxalde denis.laxalde at logilab.fr
Tue Oct 1 12:36:34 CEST 2019


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1569920307 -7200
#      Tue Oct 01 10:58:27 2019 +0200
# Node ID 9981e1a4c587066b5ddc3736faab8d8a20992a96
# Parent  d98e4759b2c707b4ad9efe00816929f3b15fe577
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 9981e1a4c587
[py3] Add a key function to sort other record ids

We need to handle local_type being None and thus not being comparable
with a string in python3.

diff --git a/cubicweb_eac/entities.py b/cubicweb_eac/entities.py
index 4cabc56..f29822c 100644
--- a/cubicweb_eac/entities.py
+++ b/cubicweb_eac/entities.py
@@ -58,7 +58,8 @@ class AuthorityRecord(AnyEntity):
     @property
     def other_record_ids(self):
         return sorted([(r.local_type, r.value)
-                       for r in self.reverse_eac_other_record_id_of])
+                       for r in self.reverse_eac_other_record_id_of],
+                      key=lambda x: (x[0] or "", x[1]))
 
 
 class AgentKind(AnyEntity):



More information about the saem-devel mailing list