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

Method __getitem__

mongoengine/base/datastructures.py:63–77  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

61 return default
62
63 def __getitem__(self, key):
64 value = super().__getitem__(key)
65
66 EmbeddedDocument = _import_class("EmbeddedDocument")
67 if isinstance(value, EmbeddedDocument) and value._instance is None:
68 value._instance = self._instance
69 elif isinstance(value, dict) and not isinstance(value, BaseDict):
70 value = BaseDict(value, None, f"{self._name}.{key}")
71 super().__setitem__(key, value)
72 value._instance = self._instance
73 elif isinstance(value, list) and not isinstance(value, BaseList):
74 value = BaseList(value, None, f"{self._name}.{key}")
75 super().__setitem__(key, value)
76 value._instance = self._instance
77 return value
78
79 def __getstate__(self):
80 self.instance = None

Callers 2

getMethod · 0.95
__getitem__Method · 0.45

Calls 4

_import_classFunction · 0.90
BaseDictClass · 0.85
BaseListClass · 0.85
__setitem__Method · 0.45

Tested by

no test coverage detected