566
567
class GoogleBatchNavigator(BatchNavigator):
567
568
"""A batch navigator with a fixed size of 20 items per batch."""
570
_batch_factory = WindowedListBatch
569
571
# Searches generally don't show the 'Last' link when there is a
570
572
# good chance of getting over 100,000 results.
571
573
show_last_link = False
573
575
singular_heading = 'page'
574
576
plural_heading = 'pages'
576
def __init__(self, results, request, start=0, size=20, callback=None):
578
def __init__(self, results, request, start=0, size=20, callback=None,
579
transient_parameters=None, force_start=False,
577
581
"""See `BatchNavigator`.
579
583
:param results: A `PageMatches` object that contains the matching
584
588
:param size: The batch size is fixed to 20, The param is not used.
585
589
:param callback: Not used.
587
# We do not want to call super() because it will use the batch
589
# pylint: disable-msg=W0231
590
591
results = WindowedList(results, start, results.total)
591
self.request = request
592
request_start = request.get(self.start_variable_name, None)
593
if request_start is None:
597
self.start = int(request_start)
598
except (ValueError, TypeError):
592
super(GoogleBatchNavigator, self).__init__(results, request,
593
start=start, size=size, callback=callback,
594
transient_parameters=transient_parameters, force_start=force_start,
595
range_factory=range_factory)
597
def determineSize(self, size, batch_params_source):
598
# Force the default and users requested sizes to 20.
601
599
self.default_size = 20
603
self.transient_parameters = [self.start_variable_name]
605
self.batch = WindowedListBatch(
606
results, start=self.start, size=self.default_size)
608
self.default_singular_heading, self.default_plural_heading)