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

Method build_lazyref

mongoengine/fields.py:2579–2596  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

2577 super()._validate_choices(value)
2578
2579 def build_lazyref(self, value):
2580 if isinstance(value, LazyReference):
2581 if value.passthrough != self.passthrough:
2582 value = LazyReference(
2583 value.document_type, value.pk, passthrough=self.passthrough
2584 )
2585 elif value is not None:
2586 if isinstance(value, (dict, SON)):
2587 value = LazyReference(
2588 get_document(value["_cls"]),
2589 value["_ref"].id,
2590 passthrough=self.passthrough,
2591 )
2592 elif isinstance(value, Document):
2593 value = LazyReference(
2594 type(value), value.pk, passthrough=self.passthrough
2595 )
2596 return value
2597
2598 def __get__(self, instance, owner):
2599 if instance is None:

Callers 1

__get__Method · 0.95

Calls 2

LazyReferenceClass · 0.90
get_documentFunction · 0.90

Tested by

no test coverage detected