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