예제 #1
0
파일: cursor.py 프로젝트: govdata/APyMongo
    def _refresh(self):
        """Refreshes the cursor with more data from Mongo.

        """

        callback = self.loop
        
        
        if self.__id is None: 
            self.__send_message(
                message.query(self.__query_options(),
                              self.__collection.full_name,
                              self.__skip, self.__limit,
                              self.__query_spec(), self.__fields),callback)

        elif self.__id:  # Get More
            if self.__limit:
                limit = self.__limit - self.__retrieved
                if self.__batch_size:
                    limit = min(limit, self.__batch_size)
            else:
                limit = self.__batch_size

            self.__send_message(
                message.get_more(self.__collection.full_name,
                                 limit, self.__id),callback)
예제 #2
0
    def _refresh(self):
        """Refreshes the cursor with more data from Mongo.

        Returns the length of self.__data after refresh. Will exit early if
        self.__data is already non-empty. Raises OperationFailure when the
        cursor cannot be refreshed due to an error on the query.
        """

        callback = self.loop

        if self.__id is None:
            self.__send_message(
                message.query(self.__query_options(),
                              self.__collection.full_name, self.__skip,
                              self.__limit, self.__query_spec(),
                              self.__fields), callback)

        elif self.__id:  # Get More
            if self.__limit:
                limit = self.__limit - self.__retrieved
                if self.__batch_size:
                    limit = min(limit, self.__batch_size)
            else:
                limit = self.__batch_size

            self.__send_message(
                message.get_more(self.__collection.full_name, limit,
                                 self.__id), callback)
예제 #3
0
파일: cursor.py 프로젝트: ebottabi/apymongo
    def _refresh(self):
        """Refreshes the cursor with more data from Mongo.

        Returns the length of self.__data after refresh. Will exit early if
        self.__data is already non-empty. Raises OperationFailure when the
        cursor cannot be refreshed due to an error on the query.
        """

        callback = self.loop

        if self.__id is None:
            self.__send_message(
                message.query(
                    self.__query_options(),
                    self.__collection.full_name,
                    self.__skip,
                    self.__limit,
                    self.__query_spec(),
                    self.__fields,
                ),
                callback,
            )

        elif self.__id:  # Get More
            if self.__limit:
                limit = self.__limit - self.__retrieved
                if self.__batch_size:
                    limit = min(limit, self.__batch_size)
            else:
                limit = self.__batch_size

            self.__send_message(message.get_more(self.__collection.full_name, limit, self.__id), callback)
예제 #4
0
 def __simple_command(self, sock_info, dbname, spec):
     """Send a command to the server.
     """
     rqst_id, msg, _ = message.query(0, dbname + '.$cmd', 0, -1, spec)
     sock_info.sock.sendall(msg)
     response = self.__recv_msg(1, rqst_id, sock_info)
     response = helpers._unpack_response(response)['data'][0]
     msg = "command %r failed: %%s" % spec
     helpers._check_command_response(response, None, msg)
     return response
예제 #5
0
파일: cursor.py 프로젝트: ohardy/APyMongo
 def _refresh(self):
     """Refreshes the cursor with more data from Mongo.
     
     """
     
     if len(self.__data) or self.__killed:
         return len(self.__data)
     
     callback = self.loop
     
     def mod_callback(response):
         """docstring for mod_callback"""
         if not self.__id:
             self.__killed = True
                 
         callback(response)
     if self.__id is None:
         ntoreturn = self.__batch_size
         if self.__limit:
             if self.__batch_size:
                 ntoreturn = min(self.__limit, self.__batch_size)
             else:
                 ntoreturn = self.__limit
         self.__send_message(
             message.query(self.__query_options(),
                           self.__collection.full_name,
                           self.__skip, ntoreturn,
                           self.__query_spec(), self.__fields,
                           self.__uuid_subtype), mod_callback)
     
     elif self.__id:  # Get More
         if self.__limit:
             limit = self.__limit - self.__retrieved
             if self.__batch_size:
                 limit = min(limit, self.__batch_size)
         else:
             limit = self.__batch_size
         
         self.__send_message(
             message.get_more(self.__collection.full_name,
                              limit, self.__id), mod_callback)