# Path: apymongo/helpers.py
# def _index_list(key_or_list, direction=None):
# def _index_document(index_list):
# def _unpack_response(response, cursor_id=None, as_class=dict, tz_aware=False):
# def _check_command_response(response, reset, msg="%s", allowable_errors=[]):
# def _password_digest(username, password):
# def _auth_key(nonce, username, password):
# def _fields_list_to_dict(fields):
# 
# Path: apymongo/message.py
# __ZERO = "\x00\x00\x00\x00"
# def __last_error(args):
# def __pack_message(operation, data):
# def insert(collection_name, docs, check_keys, safe, last_error_args):
# def update(collection_name, upsert, multi, spec, doc, safe, last_error_args):
# def query(options, collection_name,
#           num_to_skip, num_to_return, query, field_selector=None):
# def get_more(collection_name, num_to_return, cursor_id):
# def delete(collection_name, spec, safe, last_error_args):
# def kill_cursors(cursor_ids):
# 
# Path: apymongo/errors.py
# class InvalidOperation(PyMongoError):
#     """Raised when a client attempts to perform an invalid operation.
#     """
# 
# class AutoReconnect(ConnectionFailure):
#     """Raised when a connection to the database is lost and an attempt to
#     auto-reconnect will be made.
# 
#     In order to auto-reconnect you must handle this exception, recognizing that
#     the operation which caused it has not necessarily succeeded. Future
#     operations will attempt to open a new connection to the database (and
#     will continue to raise this exception until the first successful
#     connection is made).
#     """


import functools
from bson.code import Code
from bson.son import SON
from apymongo import (helpers,
                     message)
from apymongo.errors import (InvalidOperation,
                            AutoReconnect)
                    connection_id = None
        
                self.__connection_id = connection_id
        
                try:
                    response = helpers._unpack_response(response, self.__id,
                                                        self.__as_class,
                                                        self.__tz_aware)
                except AutoReconnect:
                    db.connection.disconnect()
                    raise
                    
                self.__id = response["cursor_id"]
                 
                # starting from doesn't get set on getmore's for tailable cursors
                if not self.__tailable:                    
                    assert response["starting_from"] == self.__retrieved
        
                self.__retrieved += response["number_returned"]
                self.__data = response["data"]
        
                die_now = (self.__id == 0) or (len(self.__data) == 0) or (self.__limit and self.__id and self.__limit <= self.__retrieved)
        
                if die_now:
                    self.__die()
                                
                
            callback()
    


# Path: apymongo/helpers.py
# def _index_list(key_or_list, direction=None):
# def _index_document(index_list):
# def _unpack_response(response, cursor_id=None, as_class=dict, tz_aware=False):
# def _check_command_response(response, reset, msg="%s", allowable_errors=[]):
# def _password_digest(username, password):
# def _auth_key(nonce, username, password):
# def _fields_list_to_dict(fields):
# 
# Path: apymongo/message.py
# __ZERO = "\x00\x00\x00\x00"
# def __last_error(args):
# def __pack_message(operation, data):
# def insert(collection_name, docs, check_keys, safe, last_error_args):
# def update(collection_name, upsert, multi, spec, doc, safe, last_error_args):
# def query(options, collection_name,
#           num_to_skip, num_to_return, query, field_selector=None):
# def get_more(collection_name, num_to_return, cursor_id):
# def delete(collection_name, spec, safe, last_error_args):
# def kill_cursors(cursor_ids):
# 
# Path: apymongo/errors.py
# class InvalidOperation(PyMongoError):
#     """Raised when a client attempts to perform an invalid operation.
#     """
# 
# class AutoReconnect(ConnectionFailure):
#     """Raised when a connection to the database is lost and an attempt to
#     auto-reconnect will be made.
# 
#     In order to auto-reconnect you must handle this exception, recognizing that
#     the operation which caused it has not necessarily succeeded. Future
#     operations will attempt to open a new connection to the database (and
#     will continue to raise this exception until the first successful
#     connection is made).
#     """


# Path: apymongo/cursor.py
import functools
from bson.code import Code
from bson.son import SON
from apymongo import (helpers,
                     message)
from apymongo.errors import (InvalidOperation,
                            AutoReconnect)

                    connection_id = None
        
                self.__connection_id = connection_id
        
                try:
                    response = helpers._unpack_response(response, self.__id,
                                                        self.__as_class,
                                                        self.__tz_aware)
                except AutoReconnect:
                    db.connection.disconnect()
                    raise
                    
                self.__id = response["cursor_id"]
                 
                # starting from doesn't get set on getmore's for tailable cursors
                if not self.__tailable:                    
                    assert response["starting_from"] == self.__retrieved
        
                self.__retrieved += response["number_returned"]
                self.__data = response["data"]
        
                die_now = (self.__id == 0) or (len(self.__data) == 0) or (self.__limit and self.__id and self.__limit <= self.__retrieved)
        
                if die_now:
                    self.__die()
                                
                
            callback()
    


        db.connection._send_message_with_response(message,mod_callback)