From 52a3267ead37582f49b0f0c9ddcdc2f13d2eae2e Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Mon, 28 Sep 2020 15:35:11 +0200 Subject: [PATCH] No longer consider calling len(batch) as deprecated. The deprecation warning is unvoidable with current `Products.PageTemplates` code. Fixes https://github.com/plone/Products.CMFPlone/issues/3176 --- Products/CMFPlone/PloneBatch.py | 15 ++++++++++----- news/3176.bugfix | 4 ++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 news/3176.bugfix diff --git a/Products/CMFPlone/PloneBatch.py b/Products/CMFPlone/PloneBatch.py index 2f8737297c..68687dc93a 100644 --- a/Products/CMFPlone/PloneBatch.py +++ b/Products/CMFPlone/PloneBatch.py @@ -20,12 +20,17 @@ def __init__(self, sequence, size, start=0, end=0, orphan=0, self.b_start_str = b_start_str def __len__(self): + # Note: Using len() was deprecated for several years. + # It was recommended to explicitly either use the `length` attribute + # for the size of the current page, which is what we return now, + # or use the `sequence_length` attribute for the size of the + # entire sequence. + # But the deprecation was reverted for Plone 5.2.3, + # because core code in Products.PageTemplates called `len` + # on batches, making the deprecation warning unavoidable + # and thus unnecessary. + # See https://github.com/plone/Products.CMFPlone/issues/3176 return self.length - __len__ = deprecated(__len__, - ('Using len() is deprecated. Use the `length` attribute for the ' - 'size of the current page, which is what we return now. ' - 'Use the `sequence_length` attribute for the size of the ' - 'entire sequence. ')) def __bool__(self): # Without __bool__ a bool(self) would call len(self), which diff --git a/news/3176.bugfix b/news/3176.bugfix new file mode 100644 index 0000000000..56e075e5e5 --- /dev/null +++ b/news/3176.bugfix @@ -0,0 +1,4 @@ +No longer consider calling ``len(batch)`` as deprecated. +The deprecation warning is unvoidable with current ``Products.PageTemplates`` code. +Fixes `issue 3176 `_. +maurits