def next_query(self): queries = [qry for qry in self.context.pending_request().next_query()] if len(queries) > 0: batch_qry = BatchQuery( self.context, queries) # Aggregate requests into batch request self._current_query = batch_qry yield batch_qry
def execute_batch(self): """Construct and submit a batch request""" batch_request = ODataV4BatchRequest(self) queries = [qry for qry in self.pending_request().next_query()] batch_request.add_query(BatchQuery( self, queries)) # Aggregate requests into batch request batch_request.execute_query()
def __iter__(self): queries = [qry for qry in self.context.pending_request()] if len(queries) > 0: batch_qry = BatchQuery( self.context, queries) # Aggregate requests into batch request self.context.clear_queries() self._queries = [batch_qry] yield batch_qry
def execute_batch(self, items_per_batch=100): """ Construct and submit a batch request :param int items_per_batch: Maximum to be selected for bulk operation """ batch_request = ODataBatchRequest(self) def _prepare_batch_request(request): self.ensure_form_digest(request) batch_request.beforeExecute += _prepare_batch_request all_queries = [qry for qry in self.pending_request().next_query()] for i in range_or_xrange(0, len(all_queries), items_per_batch): queries = all_queries[i:i + items_per_batch] batch_request.add_query(BatchQuery(self, queries)) batch_request.execute_query()