From 6c4586f7dd219c99ae0f520d3d6afe3e8e74e168 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Thu, 30 Nov 2023 12:23:22 +0100 Subject: [PATCH] Fix `KeyError: time` on import of content with workflow without `time` variable. Fixes https://github.com/collective/collective.exportimport/issues/222 --- CHANGES.rst | 3 +++ src/collective/exportimport/import_content.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 10267e0b..b74be6cb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Changelog 1.11 (unreleased) ----------------- +- Fix ``KeyError: time`` when importing content with a workflow that does not have the ``time`` variable. + [maurits] + - Allow to use fix_html_in_content_fields without applying the default html_fixer. [pbauer] diff --git a/src/collective/exportimport/import_content.py b/src/collective/exportimport/import_content.py index 87c88445..895cef6e 100644 --- a/src/collective/exportimport/import_content.py +++ b/src/collective/exportimport/import_content.py @@ -816,9 +816,10 @@ def import_workflow_history(self, obj, item): for key, value in workflow_history.items(): # The time needs to be deserialized for history_item in value: - history_item["time"] = DateTime( - dateutil.parser.parse(history_item["time"]) - ) + if "time" in history_item: + history_item["time"] = DateTime( + dateutil.parser.parse(history_item["time"]) + ) result[key] = value if result: obj.workflow_history = PersistentMapping(result.items())