585 result.extend(data) |
585 result.extend(data) |
586 offset = offset + chunk |
586 offset = offset + chunk |
587 |
587 |
588 return result |
588 return result |
589 |
589 |
590 def getBatchOfData(self, filter=None, order=None, start_key=None, batch_size=10): |
590 def getBatchOfData(self, filter=None, start_key=None, batch_size=10): |
591 """Returns one batch of entities |
591 """Returns one batch of entities |
592 |
592 |
593 Args: |
593 Args: |
594 filter: a dict for the properties that the entities should have |
594 filter: a dict for the properties that the entities should have |
595 order: a list with the sort order |
|
596 next_key: a key for the first entity that should be returned |
595 next_key: a key for the first entity that should be returned |
597 batch_size: the maximum amount of entities that should be fetched |
596 batch_size: the maximum amount of entities that should be fetched |
598 |
597 |
599 Returns: |
598 Returns: |
600 A tuple: list of fetched entities and key value for the entity |
599 A tuple: list of fetched entities and key value for the entity |
601 that should be fetched at first for the next batch |
600 that should be fetched at first for the next batch |
602 """ |
601 """ |
603 |
602 |
604 batch_size = min(999, batch_size) |
603 batch_size = min(999, batch_size) |
605 |
604 |
606 query = self.getQueryForFields(filter=filter, order=order) |
605 query = self.getQueryForFields(filter=filter) |
607 |
606 |
608 if start_key: |
607 if start_key: |
609 query.filter('__key__ >=', start_key) |
608 query.filter('__key__ >=', start_key) |
610 |
609 |
611 entities = query.fetch(batch_size + 1) |
610 entities = query.fetch(batch_size + 1) |