txmongo.protocol.Query

Here are the examples of the python api txmongo.protocol.Query taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: txmongo Source File: connection.py
Function: ping
    def ping(self):
        def on_ok(result):
            if timeout_call.active():
                timeout_call.cancel()
                self.__next_call = reactor.callLater(self.interval, self.ping)

        def on_fail(failure):
            if timeout_call.active():
                timeout_call.cancel()
                on_timeout()

        def on_timeout():
            self.transport.loseConnection()
            self.fail_callback(self.transport.getPeer())

        timeout_call = reactor.callLater(self.timeout, on_timeout)

        self.send_QUERY(Query(collection="admin.$cmd", query={"ismaster": 1}))\
            .addCallbacks(on_ok, on_fail)

Example 2

Project: txmongo Source File: test_protocol.py
    def test_EncodeDecodeQuery(self):
        request = Query(collection="coll", n_to_skip=123, n_to_return=456,
                        query=BSON.encode({'x': 42}),
                        fields=BSON.encode({'y': 1}))
        self.__test_encode_decode(request)

Example 3

Project: txmongo Source File: connection.py
    @staticmethod
    @timeout
    def __send_ismaster(proto, **kwargs):
        query = Query(collection="admin.$cmd", query={"ismaster": 1})
        return proto.send_QUERY(query)