~ubuntu-branches/ubuntu/wily/pymongo/wily-proposed

« back to all changes in this revision

Viewing changes to pymongo/response.py

  • Committer: Package Import Robot
  • Author(s): Federico Ceratto
  • Date: 2015-04-26 22:43:13 UTC
  • mfrom: (24.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20150426224313-0hga2jphvf0rrmfe
Tags: 3.0.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014-2015 MongoDB, Inc.
 
2
#
 
3
# Licensed under the Apache License, Version 2.0 (the "License");
 
4
# you may not use this file except in compliance with the License.
 
5
# You may obtain a copy of the License at
 
6
#
 
7
# http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
# Unless required by applicable law or agreed to in writing, software
 
10
# distributed under the License is distributed on an "AS IS" BASIS,
 
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
12
# See the License for the specific language governing permissions and
 
13
# limitations under the License.
 
14
 
 
15
"""Represent a response from the server."""
 
16
 
 
17
 
 
18
class Response(object):
 
19
    __slots__ = ('_data', '_address')
 
20
 
 
21
    def __init__(self, data, address):
 
22
        """Represent a response from the server.
 
23
 
 
24
        :Parameters:
 
25
          - `data`: Raw BSON bytes.
 
26
          - `address`: (host, port) of the source server.
 
27
        """
 
28
        self._data = data
 
29
        self._address = address
 
30
 
 
31
    @property
 
32
    def data(self):
 
33
        """Server response's raw BSON bytes."""
 
34
        return self._data
 
35
 
 
36
    @property
 
37
    def address(self):
 
38
        """(host, port) of the source server."""
 
39
        return self._address
 
40
 
 
41
 
 
42
class ExhaustResponse(Response):
 
43
    __slots__ = ('_socket_info', '_pool')
 
44
 
 
45
    def __init__(self, data, address, socket_info, pool):
 
46
        """Represent a response to an exhaust cursor's initial query.
 
47
 
 
48
        :Parameters:
 
49
          - `data`: Raw BSON bytes.
 
50
          - `address`: (host, port) of the source server.
 
51
          - `socket_info`: The SocketInfo used for the initial query.
 
52
          - `pool`: The Pool from which the SocketInfo came.
 
53
        """
 
54
        super(ExhaustResponse, self).__init__(data, address)
 
55
        self._socket_info = socket_info
 
56
        self._pool = pool
 
57
 
 
58
    @property
 
59
    def socket_info(self):
 
60
        """The SocketInfo used for the initial query.
 
61
 
 
62
        The server will send batches on this socket, without waiting for
 
63
        getMores from the client, until the result set is exhausted or there
 
64
        is an error.
 
65
        """
 
66
        return self._socket_info
 
67
 
 
68
    @property
 
69
    def pool(self):
 
70
        """The Pool from which the SocketInfo came."""
 
71
        return self._pool