From 414ac0413cc5ebeac3b6547db4c9b3828aa06dd2 Mon Sep 17 00:00:00 2001 From: akshat2jain Date: Wed, 20 Sep 2023 10:57:10 +0530 Subject: [PATCH 1/3] added uidtool --- src/Products/CMFUid/UniqueIdAnnotationTool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Products/CMFUid/UniqueIdAnnotationTool.py b/src/Products/CMFUid/UniqueIdAnnotationTool.py index 0c23b1b..a29d4e9 100644 --- a/src/Products/CMFUid/UniqueIdAnnotationTool.py +++ b/src/Products/CMFUid/UniqueIdAnnotationTool.py @@ -75,7 +75,7 @@ def handleUidAnnotationEvent(ob, event): if event.newParent is not None: anno_tool = queryUtility(IUniqueIdAnnotationManagement) uidtool = getToolByName(ob, 'portal_uidhandler', None) - if anno_tool is not None: + if anno_tool is not None and uidtool is not None: remove_on_add = anno_tool.getProperty('remove_on_add', False) remove_on_clone = anno_tool.getProperty('remove_on_clone', False) From 90e3d667499f92e5f20fc6dea8a1424a4bd91d95 Mon Sep 17 00:00:00 2001 From: akshat2jain Date: Thu, 21 Sep 2023 09:15:12 +0530 Subject: [PATCH 2/3] Prevents handleUidAnnotationEvent failure if portal_uidhandler is not available --- CHANGES.rst | 1 + src/Products/CMFUid/UniqueIdAnnotationTool.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index b43b68d..d4768c0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Products.CMFUid Changelog 4.1 (unreleased) ---------------- +- modified the code to check if both 'anno_tool' and 'uidtool' exist before using them. This change ensures that the code won't run unless both tools are available, preventing the 'NoneType' error. 4.0 (2023-02-01) ---------------- diff --git a/src/Products/CMFUid/UniqueIdAnnotationTool.py b/src/Products/CMFUid/UniqueIdAnnotationTool.py index a29d4e9..b1f676b 100644 --- a/src/Products/CMFUid/UniqueIdAnnotationTool.py +++ b/src/Products/CMFUid/UniqueIdAnnotationTool.py @@ -95,7 +95,7 @@ def handleUidAnnotationEvent(ob, event): anno_tool = queryUtility(IUniqueIdAnnotationManagement) uidtool = getToolByName(ob, 'portal_uidhandler', None) - if anno_tool is not None: + if anno_tool is not None and uidtool is not None: remove_on_clone = anno_tool.getProperty('remove_on_clone', False) assign_on_clone = anno_tool.getProperty('assign_on_clone', False) if remove_on_clone or assign_on_clone: From de78ee93f38c209cd979ec25259507a306e09cc6 Mon Sep 17 00:00:00 2001 From: akshat2jain Date: Fri, 22 Sep 2023 10:05:12 +0530 Subject: [PATCH 3/3] added log entry --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index d4768c0..a399cbe 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,7 @@ Products.CMFUid Changelog 4.1 (unreleased) ---------------- -- modified the code to check if both 'anno_tool' and 'uidtool' exist before using them. This change ensures that the code won't run unless both tools are available, preventing the 'NoneType' error. +- Modified the code of ``handleUidAnnotationEvent`` to check if both 'anno_tool' and 'uidtool' exist before using them. This change ensures that the code won't run unless both tools are available, preventing the 'NoneType' error. 4.0 (2023-02-01) ----------------