[profile gen] Avoid querying NoneType objects in SEDA1XSDExport.xsd_attachment()
authorDenis Laxalde <denis.laxalde@logilab.fr>
Mon, 16 Oct 2017 15:45:07 +0200
changeset 2775 9f9a57e950bf
parent 2774 a251b2861f32
child 2776 f84752939e76
[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.
cubicweb_seda/entities/profile_generation.py
--- a/cubicweb_seda/entities/profile_generation.py	Mon Oct 16 16:53:35 2017 +0200
+++ b/cubicweb_seda/entities/profile_generation.py	Mon Oct 16 15:45:07 2017 +0200
@@ -882,11 +882,17 @@
         _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=[