Skip to content

Commit 20a706f

Browse files
author
A. Jesse Jiryu Davis
committed
Finish updating docstrings with Connection -> MongoClient PYTHON-452
1 parent d2b23a5 commit 20a706f

File tree

6 files changed

+42
-44
lines changed

6 files changed

+42
-44
lines changed

pymongo/collection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def find(self, *args, **kwargs):
657657
examined when performing the query
658658
- `as_class` (optional): class to use for documents in the
659659
query result (default is
660-
:attr:`~pymongo.connection.Connection.document_class`)
660+
:attr:`~pymongo.mongo_client.MongoClient.document_class`)
661661
- `slave_okay` (optional): if True, allows this query to
662662
be run against a replica secondary.
663663
- `await_data` (optional): if True, the server will block for
@@ -669,7 +669,7 @@ def find(self, *args, **kwargs):
669669
outgoing SON manipulators before returning.
670670
- `network_timeout` (optional): specify a timeout to use for
671671
this query, which will override the
672-
:class:`~pymongo.connection.Connection`-level default
672+
:class:`~pymongo.mongo_client.MongoClient`-level default
673673
- `read_preference` (optional): The read preference for
674674
this query.
675675
- `tag_sets` (optional): The tag sets for this query.
@@ -845,8 +845,8 @@ def ensure_index(self, key_or_list, cache_for=300, **kwargs):
845845
actually create the index.
846846
847847
Care must be taken when the database is being accessed through
848-
multiple connections at once. If an index is created using
849-
PyMongo and then deleted using another connection any call to
848+
multiple clients at once. If an index is created using
849+
this client and deleted using another, any call to
850850
:meth:`ensure_index` within the cache window will fail to
851851
re-create the missing index.
852852
@@ -1023,7 +1023,7 @@ def aggregate(self, pipeline):
10231023
"""Perform an aggregation using the aggregation framework on this
10241024
collection.
10251025
1026-
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
1026+
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
10271027
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
10281028
if the `read_preference` attribute of this instance is not set to
10291029
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or the
@@ -1074,7 +1074,7 @@ def group(self, key, condition, initial, reduce, finalize=None):
10741074
function to be applied to each document, returning the key
10751075
to group by.
10761076
1077-
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
1077+
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
10781078
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
10791079
if the `read_preference` attribute of this instance is not set to
10801080
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or
@@ -1256,7 +1256,7 @@ def inline_map_reduce(self, map, reduce, full_response=False, **kwargs):
12561256
result documents in a list. Otherwise, returns the full
12571257
response from the server to the `map reduce command`_.
12581258
1259-
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
1259+
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
12601260
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
12611261
if the `read_preference` attribute of this instance is not set to
12621262
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or

pymongo/cursor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def count(self, with_limit_and_skip=False):
522522
`with_limit_and_skip` to ``True`` if that is the desired behavior.
523523
Raises :class:`~pymongo.errors.OperationFailure` on a database error.
524524
525-
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
525+
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
526526
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
527527
if `read_preference` is not
528528
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or
@@ -575,7 +575,7 @@ def distinct(self, key):
575575
Raises :class:`TypeError` if `key` is not an instance of
576576
:class:`basestring` (:class:`str` in python 3).
577577
578-
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
578+
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
579579
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
580580
if `read_preference` is
581581
not :attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or
@@ -798,7 +798,7 @@ def cursor_id(self):
798798
799799
Useful if you need to manage cursor ids and want to handle killing
800800
cursors manually using
801-
:meth:`~pymongo.connection.Connection.kill_cursors`
801+
:meth:`~pymongo.mongo_client.MongoClient.kill_cursors`
802802
803803
.. versionadded:: 2.2
804804
"""

pymongo/database.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def __init__(self, connection, name):
5656
database name.
5757
5858
:Parameters:
59-
- `connection`: a :class:`~pymongo.connection.Connection`
60-
instance
59+
- `connection`: a client instance
6160
- `name`: database name
6261
6362
.. mongodoc:: databases
@@ -121,8 +120,7 @@ def system_js(self):
121120

122121
@property
123122
def connection(self):
124-
"""The :class:`~pymongo.connection.Connection` instance for this
125-
:class:`Database`.
123+
"""The client instance for this :class:`Database`.
126124
127125
.. versionchanged:: 1.3
128126
``connection`` is now a property rather than a method.

pymongo/mongo_client.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(self, host=None, port=None, max_pool_size=10,
8787
document_class=dict, tz_aware=False, _connect=True, **kwargs):
8888
"""Create a new connection to a single MongoDB instance at *host:port*.
8989
90-
The resultant connection object has connection-pooling built
90+
The resultant client object has connection-pooling built
9191
in. It also performs auto-reconnection when necessary. If an
9292
operation fails because of a connection error,
9393
:class:`~pymongo.errors.ConnectionFailure` is raised. If
@@ -121,7 +121,7 @@ def __init__(self, host=None, port=None, max_pool_size=10,
121121
- `max_pool_size` (optional): The maximum number of idle connections
122122
to keep open in the pool for future use
123123
- `document_class` (optional): default class to use for
124-
documents returned from queries on this connection
124+
documents returned from queries on this client
125125
- `tz_aware` (optional): if ``True``,
126126
:class:`~datetime.datetime` instances returned as values
127127
in a document by this :class:`MongoClient` will be timezone
@@ -153,7 +153,7 @@ def __init__(self, host=None, port=None, max_pool_size=10,
153153
- `connectTimeoutMS`: (integer) How long (in milliseconds) a
154154
connection can take to be opened before timing out.
155155
- `ssl`: If ``True``, create the connection to the server using SSL.
156-
- `read_preference`: The read preference for this connection.
156+
- `read_preference`: The read preference for this client.
157157
See :class:`~pymongo.read_preferences.ReadPreference` for available
158158
options.
159159
- `auto_start_request`: If ``True``, each thread that accesses
@@ -465,14 +465,14 @@ def set_document_class(self, klass):
465465

466466
document_class = property(get_document_class, set_document_class,
467467
doc="""Default class to use for documents
468-
returned on this connection.
468+
returned from this client.
469469
470470
.. versionadded:: 1.7
471471
""")
472472

473473
@property
474474
def tz_aware(self):
475-
"""Does this connection return timezone-aware datetimes?
475+
"""Does this client return timezone-aware datetimes?
476476
477477
.. versionadded:: 1.8
478478
"""
@@ -706,7 +706,7 @@ def alive(self):
706706
707707
A more certain way to determine server availability is::
708708
709-
connection.admin.command('ping')
709+
client.admin.command('ping')
710710
711711
.. _select: http://docs.python.org/2/library/select.html#select.select
712712
"""
@@ -723,7 +723,7 @@ def alive(self):
723723
return False
724724

725725
def set_cursor_manager(self, manager_class):
726-
"""Set this connection's cursor manager.
726+
"""Set this client's cursor manager.
727727
728728
Raises :class:`TypeError` if `manager_class` is not a subclass of
729729
:class:`~pymongo.cursor_manager.CursorManager`. A cursor manager
@@ -935,10 +935,10 @@ def start_request(self):
935935
"from __future__ import with_statement", :meth:`start_request` can be
936936
used as a context manager:
937937
938-
>>> connection = pymongo.MongoClient(auto_start_request=False)
939-
>>> db = connection.test
938+
>>> client = pymongo.MongoClient(auto_start_request=False)
939+
>>> db = client.test
940940
>>> _id = db.test_collection.insert({})
941-
>>> with connection.start_request():
941+
>>> with client.start_request():
942942
... for i in range(100):
943943
... db.test_collection.update({'_id': _id}, {'$set': {'i':i}})
944944
...
@@ -1026,7 +1026,7 @@ def close_cursor(self, cursor_id):
10261026
10271027
Raises :class:`TypeError` if `cursor_id` is not an instance of
10281028
``(int, long)``. What closing the cursor actually means
1029-
depends on this connection's cursor manager.
1029+
depends on this client's cursor manager.
10301030
10311031
:Parameters:
10321032
- `cursor_id`: id of cursor to close

pymongo/mongo_replica_set_client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
274274
document_class=dict, tz_aware=False, **kwargs):
275275
"""Create a new connection to a MongoDB replica set.
276276
277-
The resultant connection object has connection-pooling built
277+
The resultant client object has connection-pooling built
278278
in. It also performs auto-reconnection when necessary. If an
279279
operation fails because of a connection error,
280280
:class:`~pymongo.errors.ConnectionFailure` is raised. If
@@ -307,7 +307,7 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
307307
- `max_pool_size` (optional): The maximum number of idle connections
308308
to keep open in each pool for future use
309309
- `document_class` (optional): default class to use for
310-
documents returned from queries on this connection
310+
documents returned from queries on this client
311311
- `tz_aware` (optional): if ``True``,
312312
:class:`~datetime.datetime` instances returned as values
313313
in a document by this :class:`MongoReplicaSetClient` will be timezone
@@ -339,7 +339,7 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
339339
- `connectTimeoutMS`: (integer) How long (in milliseconds) a
340340
connection can take to be opened before timing out.
341341
- `ssl`: If ``True``, create the connection to the servers using SSL.
342-
- `read_preference`: The read preference for this connection.
342+
- `read_preference`: The read preference for this client.
343343
See :class:`~pymongo.read_preferences.ReadPreference` for available
344344
- `tag_sets`: Read from replica-set members with these tags.
345345
To specify a priority-order for tag sets, provide a list of
@@ -598,7 +598,7 @@ def seeds(self):
598598
@property
599599
def hosts(self):
600600
"""All active and passive (priority 0) replica set
601-
members known to this connection. This does not include
601+
members known to this client. This does not include
602602
hidden or slaveDelay members, or arbiters.
603603
"""
604604
return self.__hosts
@@ -613,15 +613,15 @@ def primary(self):
613613

614614
@property
615615
def secondaries(self):
616-
"""The secondary members known to this connection.
616+
"""The secondary members known to this client.
617617
"""
618618
return set([
619619
host for host, member in self.__members.items()
620620
if member.is_secondary])
621621

622622
@property
623623
def arbiters(self):
624-
"""The arbiters known to this connection.
624+
"""The arbiters known to this client.
625625
"""
626626
return self.__arbiters
627627

@@ -665,12 +665,12 @@ def set_document_class(self, klass):
665665

666666
document_class = property(get_document_class, set_document_class,
667667
doc="""Default class to use for documents
668-
returned on this connection.
668+
returned from this client.
669669
""")
670670

671671
@property
672672
def tz_aware(self):
673-
"""Does this connection return timezone-aware datetimes?
673+
"""Does this client return timezone-aware datetimes?
674674
"""
675675
return self.__tz_aware
676676

@@ -930,7 +930,7 @@ def disconnect(self):
930930
self.__schedule_refresh()
931931

932932
def close(self):
933-
"""Close this connection instance.
933+
"""Close this client instance.
934934
935935
This method first terminates the replica set monitor, then disconnects
936936
from all members of the replica set. Once called this instance
@@ -961,7 +961,7 @@ def alive(self):
961961
962962
A more certain way to determine primary availability is to ping it::
963963
964-
connection.admin.command('ping')
964+
client.admin.command('ping')
965965
966966
.. _select: http://docs.python.org/2/library/select.html#select.select
967967
"""
@@ -1264,10 +1264,10 @@ def start_request(self):
12641264
"from __future__ import with_statement", :meth:`start_request` can be
12651265
used as a context manager:
12661266
1267-
>>> connection = pymongo.MongoReplicaSetClient()
1268-
>>> db = connection.test
1267+
>>> client = pymongo.MongoReplicaSetClient()
1268+
>>> db = client.test
12691269
>>> _id = db.test_collection.insert({})
1270-
>>> with connection.start_request():
1270+
>>> with client.start_request():
12711271
... for i in range(100):
12721272
... db.test_collection.update({'_id': _id}, {'$set': {'i':i}})
12731273
...
@@ -1356,7 +1356,7 @@ def close_cursor(self, cursor_id, _conn_id):
13561356
13571357
Raises :class:`TypeError` if `cursor_id` is not an instance of
13581358
``(int, long)``. What closing the cursor actually means
1359-
depends on this connection's cursor manager.
1359+
depends on this client's cursor manager.
13601360
13611361
:Parameters:
13621362
- `cursor_id`: id of cursor to close

pymongo/pool.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,14 @@ def __del__(self):
425425

426426
class Request(object):
427427
"""
428-
A context manager returned by Connection.start_request(), so you can do
429-
`with connection.start_request(): do_something()` in Python 2.5+.
428+
A context manager returned by :meth:`start_request`, so you can do
429+
`with client.start_request(): do_something()` in Python 2.5+.
430430
"""
431-
def __init__(self, connection):
432-
self.connection = connection
431+
def __init__(self, client):
432+
self.client = client
433433

434434
def end(self):
435-
self.connection.end_request()
435+
self.client.end_request()
436436

437437
def __enter__(self):
438438
return self

0 commit comments

Comments
 (0)