Skip to content

Commit ee5b1bb

Browse files
committed
Add alternative connection
1 parent 0ae8704 commit ee5b1bb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mongoengine/connection.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def _get_connection_settings(
7676
MONGODB-CR (MongoDB Challenge Response protocol) for older servers.
7777
:param is_mock: explicitly use mongomock for this connection
7878
(can also be done by using `mongomock: // ` as db host prefix)
79+
:param connection_class: using alternative connection client other than
80+
pymongo or mongomock, e.g. montydb, that provides pymongo alike
81+
interface but not necessarily for connecting to a real mongo instance.
7982
:param kwargs: ad-hoc parameters to be passed into the pymongo driver,
8083
for example maxpoolsize, tz_aware, etc. See the documentation
8184
for pymongo's `MongoClient` for a full list.
@@ -221,6 +224,9 @@ def register_connection(
221224
MONGODB-CR (MongoDB Challenge Response protocol) for older servers.
222225
:param is_mock: explicitly use mongomock for this connection
223226
(can also be done by using `mongomock: // ` as db host prefix)
227+
:param connection_class: using alternative connection client other than
228+
pymongo or mongomock, e.g. montydb, that provides pymongo alike
229+
interface but not necessarily for connecting to a real mongo instance.
224230
:param kwargs: ad-hoc parameters to be passed into the pymongo driver,
225231
for example maxpoolsize, tz_aware, etc. See the documentation
226232
for pymongo's `MongoClient` for a full list.
@@ -333,6 +339,10 @@ def _clean_settings(settings_dict):
333339
except ImportError:
334340
raise RuntimeError("You need mongomock installed to mock MongoEngine.")
335341
connection_class = mongomock.MongoClient
342+
343+
elif "connection_class" in conn_settings:
344+
connection_class = conn_settings.pop("connection_class")
345+
336346
else:
337347
connection_class = MongoClient
338348

0 commit comments

Comments
 (0)