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

Method get

st2common/st2common/models/db/__init__.py:528–557  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

526 return self.get(pack=value, raise_exception=True)
527
528 def get(self, *args, **kwargs):
529 exclude_fields = kwargs.pop("exclude_fields", None)
530 raise_exception = kwargs.pop("raise_exception", False)
531 only_fields = kwargs.pop("only_fields", None)
532
533 args = self._process_arg_filters(args)
534
535 instances = self.model.objects(*args, **kwargs)
536
537 if exclude_fields:
538 instances = instances.exclude(*exclude_fields)
539
540 if only_fields:
541 try:
542 instances = instances.only(*only_fields)
543 except (mongoengine.errors.LookUpError, AttributeError) as e:
544 msg = (
545 "Invalid or unsupported include attribute specified: %s"
546 % six.text_type(e)
547 )
548 raise ValueError(msg)
549
550 instance = instances[0] if instances else None
551 log_query_and_profile_data_for_queryset(queryset=instances)
552
553 if not instance and raise_exception:
554 msg = "Unable to find the %s instance. %s" % (self.model.__name__, kwargs)
555 raise db_exc.StackStormDBObjectNotFoundError(msg)
556
557 return instance
558
559 def get_all(self, *args, **kwargs):
560 return self.query(*args, **kwargs)

Callers 15

get_by_nameMethod · 0.95
get_by_idMethod · 0.95
get_by_uidMethod · 0.95
get_by_refMethod · 0.95
get_by_packMethod · 0.95
__call__Method · 0.45
custom_start_responseMethod · 0.45
__call__Method · 0.45
__call__Method · 0.45
custom_start_responseMethod · 0.45
__call__Method · 0.45
_merge_param_meta_valuesFunction · 0.45

Calls 3

_process_arg_filtersMethod · 0.95
popMethod · 0.45

Tested by

no test coverage detected