MCPcopy Create free account
hub / github.com/StackStorm/st2 / __get__

Method __get__

st2common/st2common/fields.py:493–510  ·  view source on GitHub ↗

We return a custom wrapper over dict which tracks changes to the dictionary and allows us to only write the field to the database on update if the field value has changed - very important since it means much more efficient partial updates.

(self, instance, owner)

Source from the content-addressed store, hash-verified

491 return compression_header.value + b":" + b"o:" + data
492
493 def __get__(self, instance, owner):
494 """
495 We return a custom wrapper over dict which tracks changes to the dictionary and allows us
496 to only write the field to the database on update if the field value has changed - very
497 important since it means much more efficient partial updates.
498 """
499 value = super().__get__(instance, owner)
500
501 if isinstance(value, dict) and not isinstance(value, BaseDict):
502 value = BaseDict(value, instance, self.name)
503
504 # NOTE: It's important this attribute is set, since only this way mongoengine can determine
505 # if the field has chaned or not when determing if the value should be written to the db or
506 # not
507 if instance:
508 instance._data[self.name] = value
509
510 return value
511
512
513class JSONDictEscapedFieldCompatibilityField(JSONDictField):

Callers 1

__get__Method · 0.45

Calls 1

BaseDictClass · 0.85

Tested by

no test coverage detected