Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer consider calling len(batch) as deprecated. #3187

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Products/CMFPlone/PloneBatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions news/3176.bugfix
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/plone/Products.CMFPlone/issues/3176>`_.
maurits