comparison roundup/cgi/ZTUtils/Batch.py @ 5087:39af8a0f3446

Applied patch attached to issue2550723. Problem in index page @pagesize=0 not properly propigated to previous batch link (is set to actual number of entries displayed). Using demo.py verified original issue with 0 page size. Also verified that a non-zero page size was properly propigated (values 5 and 20). Applied patch attached to issue. Verified issue with size 0 fixed. Verified that values 5 and 20 worked correctly. Updated CHANGES.txt.
author John Rouillard <rouilj@ieee.org>
date Sat, 18 Jun 2016 23:49:41 -0400
parents 6e3e4f24c753
children 35ea9b1efc14
comparison
equal deleted inserted replaced
5086:2b551b6b0830 5087:39af8a0f3446
15 ''' 15 '''
16 __docformat__ = 'restructuredtext' 16 __docformat__ = 'restructuredtext'
17 17
18 class LazyPrevBatch: 18 class LazyPrevBatch:
19 def __of__(self, parent): 19 def __of__(self, parent):
20 return Batch(parent._sequence, parent._size, 20 return Batch(parent._sequence, parent.size,
21 parent.first - parent._size + parent.overlap, 0, 21 parent.first - parent._size + parent.overlap, 0,
22 parent.orphan, parent.overlap) 22 parent.orphan, parent.overlap)
23 23
24 class LazyNextBatch: 24 class LazyNextBatch:
25 def __of__(self, parent): 25 def __of__(self, parent):
26 try: parent._sequence[parent.end] 26 try: parent._sequence[parent.end]
27 except IndexError: return None 27 except IndexError: return None
28 return Batch(parent._sequence, parent._size, 28 return Batch(parent._sequence, parent.size,
29 parent.end - parent.overlap, 0, 29 parent.end - parent.overlap, 0,
30 parent.orphan, parent.overlap) 30 parent.orphan, parent.overlap)
31 31
32 class LazySequenceLength: 32 class LazySequenceLength:
33 def __of__(self, parent): 33 def __of__(self, parent):
58 argument, is a 1-based index (I know, lame). "first" is the 58 argument, is a 1-based index (I know, lame). "first" is the
59 0-based index. "length" is the actual number of elements in 59 0-based index. "length" is the actual number of elements in
60 the batch. 60 the batch.
61 61
62 "sequence_length" is the length of the original, unbatched, sequence 62 "sequence_length" is the length of the original, unbatched, sequence
63
64 Note: "_size" is the "actual" size used to perform batch calulcations,
65 while "size" is the "representative" size. (ie. a "special value" of
66 "size" used by the templates may translate to a different value for
67 "_size" which is used internally for batch calculations).
63 ''' 68 '''
64 69
65 start = start + 1 70 start = start + 1
66 71
67 start,end,sz = opt(start,end,size,orphan,sequence) 72 start,end,sz = opt(start,end,size,orphan,sequence)
68 73
69 self._sequence = sequence 74 self._sequence = sequence
70 self.size = sz 75 self.size = size
71 self._size = size 76 self._size = sz
72 self.start = start 77 self.start = start
73 self.end = end 78 self.end = end
74 self.orphan = orphan 79 self.orphan = orphan
75 self.overlap = overlap 80 self.overlap = overlap
76 self.first = max(start - 1, 0) 81 self.first = max(start - 1, 0)

Roundup Issue Tracker: http://roundup-tracker.org/