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

Method __get__

mongoengine/queryset/manager.py:28–47  ·  view source on GitHub ↗

Descriptor for instantiating a new QuerySet object when Document.objects is accessed.

(self, instance, owner)

Source from the content-addressed store, hash-verified

26 self.get_queryset = queryset_func
27
28 def __get__(self, instance, owner):
29 """Descriptor for instantiating a new QuerySet object when
30 Document.objects is accessed.
31 """
32 if instance is not None:
33 # Document object being used rather than a document class
34 return self
35
36 # owner is the document that contains the QuerySetManager
37 queryset_class = owner._meta.get("queryset_class", self.default)
38 queryset = queryset_class(owner, owner._get_collection())
39 if self.get_queryset:
40 arg_count = self.get_queryset.__code__.co_argcount
41 if arg_count == 1:
42 queryset = self.get_queryset(queryset)
43 elif arg_count == 2:
44 queryset = self.get_queryset(owner, queryset)
45 else:
46 queryset = partial(self.get_queryset, owner, queryset)
47 return queryset
48
49
50def queryset_manager(func):

Callers

nothing calls this directly

Calls 3

_get_collectionMethod · 0.80
get_querysetMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected