Skip to content

Commit e08aa1f

Browse files
committed
PYTHON-525 Remove (ReplicaSet)Connection.
Use MongoClient or MongoReplicaSetClient instead.
1 parent 48a65eb commit e08aa1f

File tree

13 files changed

+12
-738
lines changed

13 files changed

+12
-738
lines changed

doc/api/pymongo/connection.rst

Lines changed: 0 additions & 53 deletions
This file was deleted.

doc/api/pymongo/index.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Sub-modules:
2828
.. toctree::
2929
:maxdepth: 2
3030

31-
connection
3231
database
3332
collection
3433
command_cursor
@@ -40,7 +39,6 @@ Sub-modules:
4039
mongo_client
4140
mongo_replica_set_client
4241
pool
43-
replica_set_connection
4442
son_manipulator
4543
cursor_manager
4644
uri_parser

doc/api/pymongo/replica_set_connection.rst

Lines changed: 0 additions & 45 deletions
This file was deleted.

pymongo/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ def get_version_string():
7979

8080
from pymongo.common import (MIN_SUPPORTED_WIRE_VERSION,
8181
MAX_SUPPORTED_WIRE_VERSION)
82-
from pymongo.connection import Connection
8382
from pymongo.mongo_client import MongoClient
8483
from pymongo.mongo_replica_set_client import MongoReplicaSetClient
85-
from pymongo.replica_set_connection import ReplicaSetConnection
8684
from pymongo.read_preferences import ReadPreference
8785

8886
def has_c():

pymongo/common.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def validate_timeout_or_none(option, value):
183183

184184

185185
def validate_read_preference(dummy, value):
186-
"""Validate read preference for a ReplicaSetConnection.
186+
"""Validate read preference for a MongoReplicaSetClient.
187187
"""
188188
if value in read_preferences.modes:
189189
return value
@@ -196,7 +196,7 @@ def validate_read_preference(dummy, value):
196196

197197

198198
def validate_tag_sets(dummy, value):
199-
"""Validate tag sets for a ReplicaSetConnection.
199+
"""Validate tag sets for a MongoReplicaSetClient.
200200
"""
201201
if value is None:
202202
return [{}]
@@ -359,7 +359,6 @@ def __init__(self, **options):
359359
else:
360360
self.__safe = validate_boolean('safe',
361361
options.get("safe", True))
362-
# Note: 'safe' is always passed by Connection and ReplicaSetConnection
363362
# Always do the most "safe" thing, but warn about conflicts.
364363
if self.__safe and options.get('w') == 0:
365364

@@ -370,7 +369,7 @@ def __init__(self, **options):
370369

371370
def __set_safe_option(self, option, value):
372371
"""Validates and sets getlasterror options for this
373-
object (Connection, Database, Collection, etc.)
372+
object (MongoClient, Database, Collection, etc.)
374373
"""
375374
if value is None:
376375
self.__write_concern.pop(option, None)
@@ -462,14 +461,6 @@ def __get_write_concern(self):
462461
463462
.. note:: Accessing :attr:`write_concern` returns its value
464463
(a subclass of :class:`dict`), not a copy.
465-
466-
.. warning:: If you are using :class:`~pymongo.connection.Connection`
467-
or :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
468-
make sure you explicitly set ``w`` to 1 (or a greater value) or
469-
:attr:`safe` to ``True``. Unlike calling
470-
:meth:`set_lasterror_options`, setting an option in
471-
:attr:`write_concern` does not implicitly set :attr:`safe`
472-
to ``True``.
473464
"""
474465
# To support dict style access we have to return the actual
475466
# WriteConcern here, not a copy.
@@ -524,7 +515,7 @@ def __get_tag_sets(self):
524515
To specify a priority-order for tag sets, provide a list of
525516
tag sets: ``[{'dc': 'ny'}, {'dc': 'la'}, {}]``. A final, empty tag
526517
set, ``{}``, means "read from any member that matches the mode,
527-
ignoring tags." ReplicaSetConnection tries each set of tags in turn
518+
ignoring tags." MongoReplicaSetClient tries each set of tags in turn
528519
until it finds a set of tags with at least one matching member.
529520
530521
.. seealso:: `Data-Center Awareness
@@ -678,8 +669,6 @@ def pop1(dct):
678669
# with no options if safe=True was passed but collection
679670
# level defaults have been disabled with w=0.
680671
# These should be equivalent:
681-
# Connection(w=0).foo.bar.insert({}, safe=True)
682-
# MongoClient(w=0).foo.bar.insert({}, w=1)
683672
if options.get('w') == 0:
684673
return True, {}
685674
# Passing w=0 overrides passing safe=True.

0 commit comments

Comments
 (0)