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

Method __init__

mongoengine/context_managers.py:67–76  ·  view source on GitHub ↗

Construct the switch_db context manager :param cls: the class to change the registered db :param db_alias: the name of the specific database to use

(self, cls, db_alias)

Source from the content-addressed store, hash-verified

65 """
66
67 def __init__(self, cls, db_alias):
68 """Construct the switch_db context manager
69
70 :param cls: the class to change the registered db
71 :param db_alias: the name of the specific database to use
72 """
73 self.cls = cls
74 self.collection = cls._get_collection()
75 self.db_alias = db_alias
76 self.ori_db_alias = cls._meta.get("db_alias", DEFAULT_CONNECTION_NAME)
77
78 def __enter__(self):
79 """Change the db_alias and clear the cached collection."""

Callers

nothing calls this directly

Calls 2

_get_collectionMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected