Skip to content

Commit

Permalink
Finish updating docstrings with Connection -> MongoClient PYTHON-452
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdavis committed Feb 10, 2013
1 parent d2b23a5 commit 20a706f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 44 deletions.
14 changes: 7 additions & 7 deletions pymongo/collection.py
Expand Up @@ -657,7 +657,7 @@ def find(self, *args, **kwargs):
examined when performing the query
- `as_class` (optional): class to use for documents in the
query result (default is
:attr:`~pymongo.connection.Connection.document_class`)
:attr:`~pymongo.mongo_client.MongoClient.document_class`)
- `slave_okay` (optional): if True, allows this query to
be run against a replica secondary.
- `await_data` (optional): if True, the server will block for
Expand All @@ -669,7 +669,7 @@ def find(self, *args, **kwargs):
outgoing SON manipulators before returning.
- `network_timeout` (optional): specify a timeout to use for
this query, which will override the
:class:`~pymongo.connection.Connection`-level default
:class:`~pymongo.mongo_client.MongoClient`-level default
- `read_preference` (optional): The read preference for
this query.
- `tag_sets` (optional): The tag sets for this query.
Expand Down Expand Up @@ -845,8 +845,8 @@ def ensure_index(self, key_or_list, cache_for=300, **kwargs):
actually create the index.
Care must be taken when the database is being accessed through
multiple connections at once. If an index is created using
PyMongo and then deleted using another connection any call to
multiple clients at once. If an index is created using
this client and deleted using another, any call to
:meth:`ensure_index` within the cache window will fail to
re-create the missing index.
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def aggregate(self, pipeline):
"""Perform an aggregation using the aggregation framework on this
collection.
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
if the `read_preference` attribute of this instance is not set to
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or the
Expand Down Expand Up @@ -1074,7 +1074,7 @@ def group(self, key, condition, initial, reduce, finalize=None):
function to be applied to each document, returning the key
to group by.
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
if the `read_preference` attribute of this instance is not set to
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or
Expand Down Expand Up @@ -1256,7 +1256,7 @@ def inline_map_reduce(self, map, reduce, full_response=False, **kwargs):
result documents in a list. Otherwise, returns the full
response from the server to the `map reduce command`_.
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
if the `read_preference` attribute of this instance is not set to
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or
Expand Down
6 changes: 3 additions & 3 deletions pymongo/cursor.py
Expand Up @@ -522,7 +522,7 @@ def count(self, with_limit_and_skip=False):
`with_limit_and_skip` to ``True`` if that is the desired behavior.
Raises :class:`~pymongo.errors.OperationFailure` on a database error.
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
if `read_preference` is not
:attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or
Expand Down Expand Up @@ -575,7 +575,7 @@ def distinct(self, key):
Raises :class:`TypeError` if `key` is not an instance of
:class:`basestring` (:class:`str` in python 3).
With :class:`~pymongo.replica_set_connection.ReplicaSetConnection`
With :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
or :class:`~pymongo.master_slave_connection.MasterSlaveConnection`,
if `read_preference` is
not :attr:`pymongo.read_preferences.ReadPreference.PRIMARY` or
Expand Down Expand Up @@ -798,7 +798,7 @@ def cursor_id(self):
Useful if you need to manage cursor ids and want to handle killing
cursors manually using
:meth:`~pymongo.connection.Connection.kill_cursors`
:meth:`~pymongo.mongo_client.MongoClient.kill_cursors`
.. versionadded:: 2.2
"""
Expand Down
6 changes: 2 additions & 4 deletions pymongo/database.py
Expand Up @@ -56,8 +56,7 @@ def __init__(self, connection, name):
database name.
:Parameters:
- `connection`: a :class:`~pymongo.connection.Connection`
instance
- `connection`: a client instance
- `name`: database name
.. mongodoc:: databases
Expand Down Expand Up @@ -121,8 +120,7 @@ def system_js(self):

@property
def connection(self):
"""The :class:`~pymongo.connection.Connection` instance for this
:class:`Database`.
"""The client instance for this :class:`Database`.
.. versionchanged:: 1.3
``connection`` is now a property rather than a method.
Expand Down
22 changes: 11 additions & 11 deletions pymongo/mongo_client.py
Expand Up @@ -87,7 +87,7 @@ def __init__(self, host=None, port=None, max_pool_size=10,
document_class=dict, tz_aware=False, _connect=True, **kwargs):
"""Create a new connection to a single MongoDB instance at *host:port*.
The resultant connection object has connection-pooling built
The resultant client object has connection-pooling built
in. It also performs auto-reconnection when necessary. If an
operation fails because of a connection error,
:class:`~pymongo.errors.ConnectionFailure` is raised. If
Expand Down Expand Up @@ -121,7 +121,7 @@ def __init__(self, host=None, port=None, max_pool_size=10,
- `max_pool_size` (optional): The maximum number of idle connections
to keep open in the pool for future use
- `document_class` (optional): default class to use for
documents returned from queries on this connection
documents returned from queries on this client
- `tz_aware` (optional): if ``True``,
:class:`~datetime.datetime` instances returned as values
in a document by this :class:`MongoClient` will be timezone
Expand Down Expand Up @@ -153,7 +153,7 @@ def __init__(self, host=None, port=None, max_pool_size=10,
- `connectTimeoutMS`: (integer) How long (in milliseconds) a
connection can take to be opened before timing out.
- `ssl`: If ``True``, create the connection to the server using SSL.
- `read_preference`: The read preference for this connection.
- `read_preference`: The read preference for this client.
See :class:`~pymongo.read_preferences.ReadPreference` for available
options.
- `auto_start_request`: If ``True``, each thread that accesses
Expand Down Expand Up @@ -465,14 +465,14 @@ def set_document_class(self, klass):

document_class = property(get_document_class, set_document_class,
doc="""Default class to use for documents
returned on this connection.
returned from this client.
.. versionadded:: 1.7
""")

@property
def tz_aware(self):
"""Does this connection return timezone-aware datetimes?
"""Does this client return timezone-aware datetimes?
.. versionadded:: 1.8
"""
Expand Down Expand Up @@ -706,7 +706,7 @@ def alive(self):
A more certain way to determine server availability is::
connection.admin.command('ping')
client.admin.command('ping')
.. _select: http://docs.python.org/2/library/select.html#select.select
"""
Expand All @@ -723,7 +723,7 @@ def alive(self):
return False

def set_cursor_manager(self, manager_class):
"""Set this connection's cursor manager.
"""Set this client's cursor manager.
Raises :class:`TypeError` if `manager_class` is not a subclass of
:class:`~pymongo.cursor_manager.CursorManager`. A cursor manager
Expand Down Expand Up @@ -935,10 +935,10 @@ def start_request(self):
"from __future__ import with_statement", :meth:`start_request` can be
used as a context manager:
>>> connection = pymongo.MongoClient(auto_start_request=False)
>>> db = connection.test
>>> client = pymongo.MongoClient(auto_start_request=False)
>>> db = client.test
>>> _id = db.test_collection.insert({})
>>> with connection.start_request():
>>> with client.start_request():
... for i in range(100):
... db.test_collection.update({'_id': _id}, {'$set': {'i':i}})
...
Expand Down Expand Up @@ -1026,7 +1026,7 @@ def close_cursor(self, cursor_id):
Raises :class:`TypeError` if `cursor_id` is not an instance of
``(int, long)``. What closing the cursor actually means
depends on this connection's cursor manager.
depends on this client's cursor manager.
:Parameters:
- `cursor_id`: id of cursor to close
Expand Down
28 changes: 14 additions & 14 deletions pymongo/mongo_replica_set_client.py
Expand Up @@ -274,7 +274,7 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
document_class=dict, tz_aware=False, **kwargs):
"""Create a new connection to a MongoDB replica set.
The resultant connection object has connection-pooling built
The resultant client object has connection-pooling built
in. It also performs auto-reconnection when necessary. If an
operation fails because of a connection error,
:class:`~pymongo.errors.ConnectionFailure` is raised. If
Expand Down Expand Up @@ -307,7 +307,7 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
- `max_pool_size` (optional): The maximum number of idle connections
to keep open in each pool for future use
- `document_class` (optional): default class to use for
documents returned from queries on this connection
documents returned from queries on this client
- `tz_aware` (optional): if ``True``,
:class:`~datetime.datetime` instances returned as values
in a document by this :class:`MongoReplicaSetClient` will be timezone
Expand Down Expand Up @@ -339,7 +339,7 @@ def __init__(self, hosts_or_uri=None, max_pool_size=10,
- `connectTimeoutMS`: (integer) How long (in milliseconds) a
connection can take to be opened before timing out.
- `ssl`: If ``True``, create the connection to the servers using SSL.
- `read_preference`: The read preference for this connection.
- `read_preference`: The read preference for this client.
See :class:`~pymongo.read_preferences.ReadPreference` for available
- `tag_sets`: Read from replica-set members with these tags.
To specify a priority-order for tag sets, provide a list of
Expand Down Expand Up @@ -598,7 +598,7 @@ def seeds(self):
@property
def hosts(self):
"""All active and passive (priority 0) replica set
members known to this connection. This does not include
members known to this client. This does not include
hidden or slaveDelay members, or arbiters.
"""
return self.__hosts
Expand All @@ -613,15 +613,15 @@ def primary(self):

@property
def secondaries(self):
"""The secondary members known to this connection.
"""The secondary members known to this client.
"""
return set([
host for host, member in self.__members.items()
if member.is_secondary])

@property
def arbiters(self):
"""The arbiters known to this connection.
"""The arbiters known to this client.
"""
return self.__arbiters

Expand Down Expand Up @@ -665,12 +665,12 @@ def set_document_class(self, klass):

document_class = property(get_document_class, set_document_class,
doc="""Default class to use for documents
returned on this connection.
returned from this client.
""")

@property
def tz_aware(self):
"""Does this connection return timezone-aware datetimes?
"""Does this client return timezone-aware datetimes?
"""
return self.__tz_aware

Expand Down Expand Up @@ -930,7 +930,7 @@ def disconnect(self):
self.__schedule_refresh()

def close(self):
"""Close this connection instance.
"""Close this client instance.
This method first terminates the replica set monitor, then disconnects
from all members of the replica set. Once called this instance
Expand Down Expand Up @@ -961,7 +961,7 @@ def alive(self):
A more certain way to determine primary availability is to ping it::
connection.admin.command('ping')
client.admin.command('ping')
.. _select: http://docs.python.org/2/library/select.html#select.select
"""
Expand Down Expand Up @@ -1264,10 +1264,10 @@ def start_request(self):
"from __future__ import with_statement", :meth:`start_request` can be
used as a context manager:
>>> connection = pymongo.MongoReplicaSetClient()
>>> db = connection.test
>>> client = pymongo.MongoReplicaSetClient()
>>> db = client.test
>>> _id = db.test_collection.insert({})
>>> with connection.start_request():
>>> with client.start_request():
... for i in range(100):
... db.test_collection.update({'_id': _id}, {'$set': {'i':i}})
...
Expand Down Expand Up @@ -1356,7 +1356,7 @@ def close_cursor(self, cursor_id, _conn_id):
Raises :class:`TypeError` if `cursor_id` is not an instance of
``(int, long)``. What closing the cursor actually means
depends on this connection's cursor manager.
depends on this client's cursor manager.
:Parameters:
- `cursor_id`: id of cursor to close
Expand Down
10 changes: 5 additions & 5 deletions pymongo/pool.py
Expand Up @@ -425,14 +425,14 @@ def __del__(self):

class Request(object):
"""
A context manager returned by Connection.start_request(), so you can do
`with connection.start_request(): do_something()` in Python 2.5+.
A context manager returned by :meth:`start_request`, so you can do
`with client.start_request(): do_something()` in Python 2.5+.
"""
def __init__(self, connection):
self.connection = connection
def __init__(self, client):
self.client = client

def end(self):
self.connection.end_request()
self.client.end_request()

def __enter__(self):
return self
Expand Down

0 comments on commit 20a706f

Please sign in to comment.