本文整理汇总了Python中st2common.persistence.keyvalue.KeyValuePair.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python KeyValuePair.get_all方法的具体用法?Python KeyValuePair.get_all怎么用?Python KeyValuePair.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.persistence.keyvalue.KeyValuePair
的用法示例。
在下文中一共展示了KeyValuePair.get_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_datastore
# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_all [as 别名]
def migrate_datastore():
key_value_items = KeyValuePair.get_all()
try:
for kvp in key_value_items:
kvp_id = getattr(kvp, 'id', None)
secret = getattr(kvp, 'secret', False)
scope = getattr(kvp, 'scope', SYSTEM_SCOPE)
new_kvp_db = KeyValuePairDB(id=kvp_id, name=kvp.name,
expire_timestamp=kvp.expire_timestamp,
value=kvp.value, secret=secret,
scope=scope)
KeyValuePair.add_or_update(new_kvp_db)
except:
print('ERROR: Failed migrating datastore item with name: %s' % kvp.name)
tb.print_exc()
raise
示例2: get_all
# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_all [as 别名]
def get_all(self, **kw):
"""
List all keys.
Handles requests:
GET /keys/
"""
# Prefix filtering
prefix_filter = kw.get('prefix', None)
if prefix_filter:
kw['name__startswith'] = prefix_filter
del kw['prefix']
kvp_dbs = KeyValuePair.get_all(**kw)
kvps = [KeyValuePairAPI.from_model(kvp_db) for kvp_db in kvp_dbs]
return kvps
示例3: migrate_datastore
# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_all [as 别名]
def migrate_datastore():
key_value_items = KeyValuePair.get_all()
try:
for kvp in key_value_items:
kvp_id = getattr(kvp, "id", None)
secret = getattr(kvp, "secret", False)
encrypted = getattr(kvp, "encrypted", False)
scope = getattr(kvp, "scope", SYSTEM_SCOPE)
new_kvp_db = KeyValuePairDB(
id=kvp_id,
name=kvp.name,
expire_timestamp=kvp.expire_timestamp,
value=kvp.value,
secret=secret,
encrypted=encrypted,
scope=scope,
)
KeyValuePair.add_or_update(new_kvp_db)
except:
print("ERROR: Failed migrating datastore item with name: %s" % kvp.name)
tb.print_exc()
raise