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

Method build_lazyref

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

Source from the content-addressed store, hash-verified

2448 return self.document_type_obj
2449
2450 def build_lazyref(self, value):
2451 if isinstance(value, LazyReference):
2452 if value.passthrough != self.passthrough:
2453 value = LazyReference(
2454 value.document_type, value.pk, passthrough=self.passthrough
2455 )
2456 elif value is not None:
2457 if isinstance(value, self.document_type):
2458 value = LazyReference(
2459 self.document_type, value.pk, passthrough=self.passthrough
2460 )
2461 elif isinstance(value, DBRef):
2462 value = LazyReference(
2463 self.document_type, value.id, passthrough=self.passthrough
2464 )
2465 else:
2466 # value is the primary key of the referenced document
2467 value = LazyReference(
2468 self.document_type, value, passthrough=self.passthrough
2469 )
2470 return value
2471
2472 def __get__(self, instance, owner):
2473 """Descriptor to allow lazy dereferencing."""

Callers 3

__get__Method · 0.95
to_pythonMethod · 0.95
__get__Method · 0.45

Calls 1

LazyReferenceClass · 0.90

Tested by

no test coverage detected