From 37e421f7fc73692038ccde0e57afb20d94ef509e Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Thu, 18 Aug 2022 11:54:39 +0200 Subject: [PATCH] fix returning of item_id if given. --- news/16.bugfix | 3 +++ src/plone/base/utils.py | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 news/16.bugfix diff --git a/news/16.bugfix b/news/16.bugfix new file mode 100644 index 0000000..7f5245a --- /dev/null +++ b/news/16.bugfix @@ -0,0 +1,3 @@ +Fix returning of item_id if given in `pretty_title_or_id`. +Remove unused code and outdated comment. +[jensens] diff --git a/src/plone/base/utils.py b/src/plone/base/utils.py index 252d559..c879fd8 100644 --- a/src/plone/base/utils.py +++ b/src/plone/base/utils.py @@ -185,6 +185,8 @@ def pretty_title_or_id(context, obj, empty_value=_marker): item_id = getattr(obj, "getId", None) if safe_callable(item_id): item_id = item_id() + if item_id is not None: + return item_id if empty_value is _marker: empty_value = get_empty_title(context) return empty_value