Skip to content

Commit

Permalink
added uidtool (#23)
Browse files Browse the repository at this point in the history
Prevents handleUidAnnotationEvent failure if portal_uidhandler is not available
  • Loading branch information
Akshat2Jain committed Sep 22, 2023
1 parent 7317fc7 commit cc41340
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Products.CMFUid Changelog
4.1 (unreleased)
----------------

- 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)
----------------
Expand Down
4 changes: 2 additions & 2 deletions src/Products/CMFUid/UniqueIdAnnotationTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit cc41340

Please sign in to comment.