Skip to content

Commit 1d2118e

Browse files
committed
More Connection -> MongoClient in docs PYTHON-423
1 parent 541f518 commit 1d2118e

File tree

5 files changed

+27
-28
lines changed

5 files changed

+27
-28
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ Examples
5252
Here's a basic example (for more see the *examples* section of the docs):
5353

5454
>>> import pymongo
55-
>>> connection = pymongo.Connection("localhost", 27017)
55+
>>> connection = pymongo.MongoClient("localhost", 27017)
5656
>>> db = connection.test
5757
>>> db.name
5858
u'test'
5959
>>> db.my_collection
60-
Collection(Database(Connection('localhost', 27017), u'test'), u'my_collection')
60+
Collection(Database(MongoClient('localhost', 27017), u'test'), u'my_collection')
6161
>>> db.my_collection.save({"x": 10})
6262
ObjectId('4aba15ebe23f6b53b0000000')
6363
>>> db.my_collection.save({"x": 8})

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
doctest_test_doctest_blocks = False
7171

7272
doctest_global_setup = """
73-
from pymongo.connection import Connection
74-
connection = Connection()
73+
from pymongo.mongo_client import MongoClient
74+
connection = MongoClient()
7575
connection.drop_database("doctest_test")
7676
db = connection.doctest_test
7777
"""

doc/faq.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ for threaded applications.
1414
How does connection pooling work in PyMongo?
1515
--------------------------------------------
1616

17-
Every :class:`~pymongo.connection.Connection` instance has built-in
17+
Every :class:`~pymongo.mongo_client.MongoClient` instance has built-in
1818
connection pooling. By default, each thread gets its own socket reserved on its
1919
first operation. Those sockets are held until
20-
:meth:`~pymongo.connection.Connection.end_request` is called by that
20+
:meth:`~pymongo.mongo_client.MongoClient.end_request` is called by that
2121
thread.
2222

23-
Calling :meth:`~pymongo.connection.Connection.end_request` allows the
23+
Calling :meth:`~pymongo.mongo_client.MongoClient.end_request` allows the
2424
socket to be returned to the pool, and to be used by other threads
2525
instead of creating a new socket. Judicious use of this method is
2626
important for applications with many threads or with long running
2727
threads that make few calls to PyMongo operations.
2828

29-
Alternatively, a :class:`~pymongo.connection.Connection` created with
29+
Alternatively, a :class:`~pymongo.mongo_client.MongoClient` created with
3030
``auto_start_request=False`` will share sockets (safely) among all threads.
3131

32-
When :meth:`~pymongo.connection.Connection.disconnect` is called by any thread,
32+
When :meth:`~pymongo.mongo_client.MongoClient.disconnect` is called by any thread,
3333
all sockets are closed. PyMongo will create new sockets as needed.
3434

3535
Does PyMongo support Python 3?
@@ -47,7 +47,7 @@ Currently there is no great way to use PyMongo in conjunction with `Tornado
4747
<http://www.tornadoweb.org/>`_ or `Twisted <http://twistedmatrix.com/>`_.
4848
PyMongo provides built-in connection pooling, so some of the benefits of those
4949
frameworks can be achieved just by writing multi-threaded code that shares a
50-
:class:`~pymongo.connection.Connection`.
50+
:class:`~pymongo.mongo_client.MongoClient`.
5151

5252
There are asynchronous MongoDB drivers in Python: `AsyncMongo for Tornado
5353
<https://github.com/bitly/asyncmongo>`_ and `TxMongo for Twisted
@@ -62,10 +62,10 @@ avoid blocking the event loop:
6262
`MongoDB profiler <http://www.mongodb.org/display/DOCS/Database+Profiler>`_
6363
to watch for slow queries.
6464

65-
- Create a single :class:`~pymongo.connection.Connection` instance for your
65+
- Create a single :class:`~pymongo.mongo_client.MongoClient` instance for your
6666
application in your startup code, before starting the IOLoop.
6767

68-
- Configure the :class:`~pymongo.connection.Connection` with a short
68+
- Configure the :class:`~pymongo.mongo_client.MongoClient` with a short
6969
``socketTimeoutMS`` so slow operations result in a
7070
:class:`~pymongo.errors.TimeoutError`, rather than blocking the loop and
7171
preventing your application from responding to other requests.
@@ -145,9 +145,9 @@ UTC. In versions >= 1.7, the driver will automatically convert aware
145145
datetimes to UTC before saving them. By default, datetimes retrieved
146146
from the server (no matter what version of the driver you're using)
147147
will be naive and represent UTC. In newer versions of the driver you
148-
can set the :class:`~pymongo.connection.Connection` `tz_aware`
148+
can set the :class:`~pymongo.mongo_client.MongoClient` `tz_aware`
149149
parameter to ``True``, which will cause all
150-
:class:`~datetime.datetime` instances returned from that Connection to
150+
:class:`~datetime.datetime` instances returned from that MongoClient to
151151
be aware (UTC). This setting is recommended, as it can force
152152
application code to handle timezones properly.
153153

doc/python3.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ read it back. Notice the byte string is decoded back to :class:`bytes`::
3030
[GCC 4.5.3] on linux2
3131
Type "help", "copyright", "credits" or "license" for more information.
3232
>>> import pymongo
33-
>>> c = pymongo.Connection()
33+
>>> c = pymongo.MongoClient()
3434
>>> c.test.bintest.insert({'binary': b'this is a byte string'})
3535
ObjectId('4f9086b1fba5222021000000')
3636
>>> c.test.bintest.find_one()
@@ -43,7 +43,7 @@ to :class:`~bson.binary.Binary`::
4343
[GCC 4.5.3] on linux2
4444
Type "help", "copyright", "credits" or "license" for more information.
4545
>>> import pymongo
46-
>>> c = pymongo.Connection()
46+
>>> c = pymongo.MongoClient()
4747
>>> c.test.bintest.find_one()
4848
{u'binary': Binary('this is a byte string', 0), u'_id': ObjectId('4f9086b1fba5222021000000')}
4949

@@ -151,26 +151,25 @@ directory after running ``python setup.py install`` the untranslated modules
151151
will be the first thing in your path. Importing pymongo will result in an
152152
exception similar to::
153153

154-
Python 3.1.4 (default, Mar 21 2012, 14:34:01)
155-
[GCC 4.5.3] on linux2
154+
Python 3.1.5 (default, Jun 2 2012, 12:24:49)
155+
[GCC 4.6.3] on linux2
156156
Type "help", "copyright", "credits" or "license" for more information.
157157
>>> import pymongo
158158
Traceback (most recent call last):
159159
File "<stdin>", line 1, in <module>
160-
File "pymongo/__init__.py", line 104, in <module>
161-
from pymongo.connection import Connection
162-
File "pymongo/connection.py", line 573
163-
except Exception, why:
164-
^
165-
SyntaxError: invalid syntax
160+
File "pymongo/__init__.py", line 58, in <module>
161+
version = get_version_string()
162+
File "pymongo/__init__.py", line 54, in get_version_string
163+
if isinstance(version_tuple[-1], basestring):
164+
NameError: global name 'basestring' is not defined
166165

167166
Note the path in the traceback (``pymongo/__init__.py``). Changing out of the
168167
source directory takes the untranslated modules out of your path::
169168

170169
$ cd ..
171170
$ python
172-
Python 3.1.4 (default, Mar 21 2012, 14:34:01)
173-
[GCC 4.5.3] on linux2
171+
Python 3.1.5 (default, Jun 2 2012, 12:24:49)
172+
[GCC 4.6.3] on linux2
174173
Type "help", "copyright", "credits" or "license" for more information.
175174
>>> import pymongo
176175
>>> pymongo.__file__

doc/tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ can start it like so:
2929
3030
$ mongod
3131
32-
Making a Connection
33-
-------------------
32+
Making a Connection with MongoClient
33+
------------------------------------
3434
The first step when working with **PyMongo** is to create a
3535
:class:`~pymongo.mongo_client.MongoClient` to the running **mongod**
3636
instance. Doing so is easy:

0 commit comments

Comments
 (0)