MongoClient now supports all MongoReplicaSetClient's features.
Fix bugs and add features in the new MongoClient to bring it up
to spec. MongoReplicaSetClient is now a deprecated stub that
subclasses MongoClient.
Introduce new errors, NetworkTimeout and NotMasterError, to
communicate events that MongoClient must handle specially.
This change does a few things:
- Raises a new exception for CursorNotFound, inheriting from
OperationFailure so we don't break existing code.
- Catches the exception in cursor.Cursor and command_cursor.CommandCursor,
setting __killed to True.
- If the cursor is not tailable, re-raises the exception. This makes it
easier to deal with capped collection rollover when iterating a
tailable cursor.
The idea here is to unify the handling of oversize documents when using
the bulk API in MongoDB 2.6 and previous versions. This also means that
using bulk Collection.insert against legacy servers will attempt to insert
all documents previous to the oversize document before raising.
This change adds an error_document attribute to
OperationFailure and subclasses. The error_document
attr will be the complete error document returned by
the server, when available. The error document may
include valuable information other than just the error
message, particularly when connected to mongos, which
may return one or more error subdocuments representing
errors on multiple shards.
PyMongo defines a TimeoutError exception, added in PyMongo
1.8, that is supposed to be raised if the server returns
a wtimeout error for inserts, updates, or removes. This error
has not actually been raised by the driver since MongoDB 1.8,
which changed how wtimeout is reported by the server.
This commit fixes the problem by raising a new exception,
WTimeoutError, instead of OperationFailure when the server
returns wtimeout. WTimeoutError is meant to distinguish this
particular error from other "timeout" errors handled in the
driver. It inherits from (now deprecated) TimeoutError to support
applications and libraries that already catch TimeoutError.
PYTHON-576 will add the server error document to OperationFailure
and subclasses (e.g. WTimeoutError), which can be used to check
return values like 'n', 'updatedExisting', and 'writtenTo', even
though wtimeout error occured.
Replace the 'mongo' dict with a Member object everywhere in ReplicaSetConnection.
A handful of commands obey read preferences; most are always sent to primary.
Track a 5-sample moving average of each replica set member's ping time.
Connection detects whether it's connected to primary, secondary, or mongos.
This change moves the URI parsing code out
of pymongo.connection and into a new module,
pymongo.uri_parser. It also adds validation
for all MongoDB URI options currently supported
by pymongo as well as some that will be supported
in pymongo-2.0. an UnsupportedOption error
(inheriting from ConfigurationError) is raised
if the URI includes an option pymongo doesn't
support or recognize.
The primary entry point for uri_parser is
uri_parser.parse_uri which returns a dict of the
results from parsing the URI. See the documentation
for more details
Many of the pymongo modules have been moved into the bson
package. Aliases for those modules have been added to the pymongo
package, without deprecation warnings for now. Application developers
should begin to use the bson namespace, as deprecation of moved
modules will probably begin in the next release.
Note that this is changing the exception hierarchy somewhat as well,
as I would rather not muck things up with multiple inheritance. This
is a breaking change if you depend on ConnectionFailure being an
IOError or InvalidBSON being a ValueError, for example. If this
creates issues for anybody please let us know and we can figure out a
better workaround.
Also add Michael to contributors list.