/usr/lib/python3/dist-packages/pymongo/read_concern.py is in python3-pymongo 3.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # Copyright 2015 MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License",
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tools for working with read concerns."""
from bson.py3compat import string_type
class ReadConcern(object):
"""ReadConcern
:Parameters:
- `level`: (string) The read concern level specifies the level of
isolation for read operations. For example, a read operation using a
read concern level of ``majority`` will only return data that has been
written to a majority of nodes. If the level is left unspecified, the
server default will be used.
.. versionadded:: 3.2
"""
def __init__(self, level=None):
if level is None or isinstance(level, string_type):
self.__level = level
else:
raise TypeError(
'level must be a string or None.')
@property
def level(self):
"""The read concern level."""
return self.__level
@property
def ok_for_legacy(self):
"""Return ``True`` if this read concern is compatible with
old wire protocol versions."""
return self.level is None or self.level == 'local'
@property
def document(self):
"""The document representation of this read concern.
.. note::
:class:`ReadConcern` is immutable. Mutating the value of
:attr:`document` does not mutate this :class:`ReadConcern`.
"""
doc = {}
if self.__level:
doc['level'] = self.level
return doc
def __eq__(self, other):
if isinstance(other, ReadConcern):
return self.document == other.document
return NotImplemented
def __repr__(self):
if self.level:
return 'ReadConcern(%s)' % self.level
return 'ReadConcern()'
DEFAULT_READ_CONCERN = ReadConcern()
|