MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / _get_connection_settings

Function _get_connection_settings

mongoengine/connection.py:63–221  ·  view source on GitHub ↗

Get the connection settings as a dict :param db: the name of the database to use, for compatibility with connect :param name: the name of the specific database to use :param host: the host name of the: program: `mongod` instance to connect to :param port: the port that the: program:

(
    db=None,
    name=None,
    host=None,
    port=None,
    read_preference=READ_PREFERENCE,
    username=None,
    password=None,
    authentication_source=None,
    authentication_mechanism=None,
    authmechanismproperties=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

61
62
63def _get_connection_settings(
64 db=None,
65 name=None,
66 host=None,
67 port=None,
68 read_preference=READ_PREFERENCE,
69 username=None,
70 password=None,
71 authentication_source=None,
72 authentication_mechanism=None,
73 authmechanismproperties=None,
74 **kwargs,
75):
76 """Get the connection settings as a dict
77
78 :param db: the name of the database to use, for compatibility with connect
79 :param name: the name of the specific database to use
80 :param host: the host name of the: program: `mongod` instance to connect to
81 :param port: the port that the: program: `mongod` instance is running on
82 :param read_preference: The read preference for the collection
83 :param username: username to authenticate with
84 :param password: password to authenticate with
85 :param authentication_source: database to authenticate against
86 :param authentication_mechanism: database authentication mechanisms.
87 By default, use SCRAM-SHA-1 with MongoDB 3.0 and later,
88 MONGODB-CR (MongoDB Challenge Response protocol) for older servers.
89 :param mongo_client_class: using alternative connection client other than
90 pymongo.MongoClient, e.g. mongomock, montydb, that provides pymongo alike
91 interface but not necessarily for connecting to a real mongo instance.
92 :param kwargs: ad-hoc parameters to be passed into the pymongo driver,
93 for example maxpoolsize, tz_aware, etc. See the documentation
94 for pymongo's `MongoClient` for a full list.
95 """
96 conn_settings = {
97 "name": name or db or DEFAULT_DATABASE_NAME,
98 "host": host or DEFAULT_HOST,
99 "port": port or DEFAULT_PORT,
100 "read_preference": read_preference,
101 "username": username,
102 "password": password,
103 "authentication_source": authentication_source,
104 "authentication_mechanism": authentication_mechanism,
105 "authmechanismproperties": authmechanismproperties,
106 }
107
108 _check_db_name(conn_settings["name"])
109 conn_host = conn_settings["host"]
110
111 # Host can be a list or a string, so if string, force to a list.
112 if isinstance(conn_host, str):
113 conn_host = [conn_host]
114
115 resolved_hosts = []
116 for entity in conn_host:
117 # Reject old mongomock integration
118 # To be removed in a few versions after 0.27.0
119 if entity.startswith("mongomock://") or kwargs.get("is_mock"):
120 raise Exception(

Callers 3

register_connectionFunction · 0.85
connectFunction · 0.85

Calls 6

_check_db_nameFunction · 0.85
itemsMethod · 0.80
popMethod · 0.80
keysMethod · 0.80
getMethod · 0.45
updateMethod · 0.45

Tested by 1