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

Function get_document

mongoengine/base/common.py:28–49  ·  view source on GitHub ↗

Get a registered Document class by name.

(name)

Source from the content-addressed store, hash-verified

26
27
28def get_document(name):
29 """Get a registered Document class by name."""
30 doc = _document_registry.get(name, None)
31 if not doc:
32 # Possible old style name
33 single_end = name.split(".")[-1]
34 compound_end = ".%s" % single_end
35 possible_match = [
36 k for k in _document_registry if k.endswith(compound_end) or k == single_end
37 ]
38 if len(possible_match) == 1:
39 doc = _document_registry.get(possible_match.pop(), None)
40 if not doc:
41 raise NotRegistered(
42 """
43 `%s` has not been registered in the document registry.
44 Importing the document class automatically registers it, has it
45 been imported?
46 """.strip()
47 % name
48 )
49 return doc
50
51
52def _get_documents_by_db(connection_alias, default_connection_alias):

Callers 15

_find_referencesMethod · 0.90
_fetch_objectsMethod · 0.90
_attach_objectsMethod · 0.90
document_typeMethod · 0.90
to_pythonMethod · 0.90
to_pythonMethod · 0.90
document_typeMethod · 0.90
__get__Method · 0.90
document_typeMethod · 0.90
__get__Method · 0.90
document_typeMethod · 0.90
build_lazyrefMethod · 0.90

Calls 3

NotRegisteredClass · 0.90
popMethod · 0.80
getMethod · 0.45

Tested by 1