Skip to content

Commit

Permalink
provide backwards compatible __len__ method
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Gross committed Dec 17, 2011
1 parent f58605e commit 84bdce6
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Products/CMFPlone/PloneBatch.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
# XXX do we want to expose this?
#from plone.sequencebatch.batch import (
# calculate_pagenumber, calculate_pagenumber,
# calculate_quantum_leap_gap, calculate_leapback,
# calculate_leapforward)

from ZTUtils import make_query

from plone.batching.batch import QuantumBatch
from plone.batching.utils import calculate_pagerange
#from plone.batching.utils import (
# opt, calculate_pagenumber,
# calculate_leapback, calculate_leapforward)

#from copy import copy
from zope.deprecation import deprecated

class Batch(QuantumBatch):

Expand All @@ -25,6 +16,12 @@ def __init__(self, sequence, size, start=0, end=0, orphan=0,
pagerange, quantumleap)
self.b_start_str = b_start_str

def __len__(self):
return self.length
__len__ = deprecated(__len__,
('Using len() for getting the actual pagesize is deprecated. Use the '
'`pagesize` attribute instead.'))

def initialize(self, start, end, size):
super(Batch, self).initialize(start, end, size)
self.pagerange, self.pagerangestart, self.pagerangeend = calculate_pagerange(
Expand Down

0 comments on commit 84bdce6

Please sign in to comment.