mongo_replica_set_client.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2011-2015 MongoDB, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you
  4. # may not use this file except in compliance with the License. You
  5. # may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. # implied. See the License for the specific language governing
  13. # permissions and limitations under the License.
  14. """Deprecated. See :doc:`/examples/high_availability`."""
  15. import warnings
  16. from pymongo import mongo_client
  17. class MongoReplicaSetClient(mongo_client.MongoClient):
  18. """Deprecated alias for :class:`~pymongo.mongo_client.MongoClient`.
  19. :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`
  20. will be removed in a future version of PyMongo.
  21. .. versionchanged:: 3.0
  22. :class:`~pymongo.mongo_client.MongoClient` is now the one and only
  23. client class for a standalone server, mongos, or replica set.
  24. It includes the functionality that had been split into
  25. :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`: it
  26. can connect to a replica set, discover all its members, and monitor
  27. the set for stepdowns, elections, and reconfigs.
  28. The ``refresh`` method is removed from
  29. :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`,
  30. as are the ``seeds`` and ``hosts`` properties.
  31. """
  32. def __init__(self, *args, **kwargs):
  33. warnings.warn('MongoReplicaSetClient is deprecated, use MongoClient'
  34. ' to connect to a replica set',
  35. DeprecationWarning, stacklevel=2)
  36. super(MongoReplicaSetClient, self).__init__(*args, **kwargs)
  37. def __repr__(self):
  38. return "MongoReplicaSetClient(%s)" % (self._repr_helper(),)