app/soc/logic/models/base.py
changeset 2992 c860b26481be
parent 2989 4ab340430bfa
child 2994 24db4afbc82e
equal deleted inserted replaced
2991:d6efef2989ac 2992:c860b26481be
   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, next_key=None, batch_size=10):
   590   def getBatchOfData(self, filter=None, order=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
   595       order: a list with the sort order
   603 
   603 
   604     batch_size = min(999, batch_size)
   604     batch_size = min(999, batch_size)
   605 
   605 
   606     query = self.getQueryForFields(filter=filter, order=order)
   606     query = self.getQueryForFields(filter=filter, order=order)
   607 
   607 
   608     if next_key is not None:
   608     if start_key:
   609       query.filter('__key__ >=', next_key)
   609       query.filter('__key__ >=', start_key)
   610 
   610 
   611     entities = query.fetch(batch_size + 1)
   611     entities = query.fetch(batch_size + 1)
   612 
   612 
   613     next_key = None
   613     next_start_key = None
   614     if len(entities) == batch_size + 1:
   614     if len(entities) == batch_size + 1:
   615       next_entity = entities.pop()
   615       next_entity = entities.pop()
   616       next_key = next_entity.key()
   616       next_start_key = next_entity.key()
   617 
   617 
   618     return entities, next_key
   618     return entities, next_start_key
   619 
   619 
   620   # pylint: disable-msg=C0103
   620   # pylint: disable-msg=C0103
   621   def entityIterator(self, queryGen, batch_size=100):
   621   def entityIterator(self, queryGen, batch_size=100):
   622     """Iterator that yields an entity in batches.
   622     """Iterator that yields an entity in batches.
   623 
   623