[PATCH seda] [profile gen] Avoid querying NoneType objects in SEDA1XSDExport.xsd_attachment()

Denis Laxalde denis.laxalde at logilab.fr
Mon Oct 16 16:06:10 CEST 2017


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1508161507 -7200
#      Mon Oct 16 15:45:07 2017 +0200
# Node ID 54c9cd3d85f0bb2a6f5d74f91fac6a184307d617
# Parent  2c05e49c43c88e412df00116f01eca3dc25eb4d1
[profile gen] Avoid querying NoneType objects in SEDA1XSDExport.xsd_attachment()

Follow-up on cc3b3e0f6d42 to fix recurring "AttributeError: 'NoneType'
object has no attribute 'concepts'" observed in demo's logs.

diff --git a/cubicweb_seda/entities/profile_generation.py b/cubicweb_seda/entities/profile_generation.py
--- a/cubicweb_seda/entities/profile_generation.py
+++ b/cubicweb_seda/entities/profile_generation.py
@@ -882,11 +882,17 @@ class SEDA1XSDExport(SEDA2ExportAdapter)
         _safe_concept = partial(_safe_concept_value, concepts_language=self.concepts_language)
 
         format_id = data_object.format_id
-        format_ids = [_concept_value(concept, self.concepts_language)
-                      for concept in format_id.concepts]
+        if format_id is not None:
+            format_ids = [_concept_value(concept, self.concepts_language)
+                          for concept in format_id.concepts]
+        else:
+            format_ids = []
         mime_type = data_object.mime_type
-        mime_types = [_concept_value(concept, self.concepts_language)
-                      for concept in mime_type.concepts]
+        if mime_type is not None:
+            mime_types = [_concept_value(concept, self.concepts_language)
+                          for concept in mime_type.concepts]
+        else:
+            mime_types = []
         encoding = data_object.encoding
         self.element_schema(parent, 'Attachment', 'qdt:ArchivesBinaryObjectType',
                             xsd_attributes=[



More information about the saem-devel mailing list