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

Method _get

st2common/st2common/services/keyvalues.py:244–268  ·  view source on GitHub ↗
(self, name)

Source from the content-addressed store, hash-verified

242 return self._get(name)
243
244 def _get(self, name):
245 # get the value for this key and save in value_cache
246 if self._key_prefix:
247 key = "%s.%s" % (self._key_prefix, name)
248 else:
249 key = UserKeyReference(name=name, user=self._user).ref
250
251 if self._prefix:
252 kvp_key = DATASTORE_KEY_SEPARATOR.join([self._prefix, key])
253 else:
254 kvp_key = key
255
256 value = self._get_kv(kvp_key)
257 self._value_cache[key] = value
258 # return a KeyValueLookup as response since the lookup may not be complete e.g. if
259 # the lookup is for 'key_base.key_value' it is likely that the calling code, e.g. Jinja,
260 # will expect to do a dictionary style lookup for key_base and key_value as subsequent
261 # calls. Saving the value in cache avoids extra DB calls.
262 return UserKeyValueLookup(
263 prefix=self._prefix,
264 user=self._user,
265 key_prefix=key,
266 cache=self._value_cache,
267 scope=self._scope,
268 )
269
270 def _get_kv(self, key):
271 scope = self._scope

Callers 2

__getitem__Method · 0.95
__getattr__Method · 0.95

Calls 3

_get_kvMethod · 0.95
UserKeyReferenceClass · 0.90
UserKeyValueLookupClass · 0.85

Tested by

no test coverage detected