本文整理汇总了Python中crashstats.supersearch.models.SuperSearchFields.itervalues方法的典型用法代码示例。如果您正苦于以下问题:Python SuperSearchFields.itervalues方法的具体用法?Python SuperSearchFields.itervalues怎么用?Python SuperSearchFields.itervalues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crashstats.supersearch.models.SuperSearchFields
的用法示例。
在下文中一共展示了SuperSearchFields.itervalues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_from_es
# 需要导入模块: from crashstats.supersearch.models import SuperSearchFields [as 别名]
# 或者: from crashstats.supersearch.models.SuperSearchFields import itervalues [as 别名]
def get_from_es(namespace, baseline=None):
# @namespace is something like 'raw_crash' or 'processed_crash'
cache_key = 'api_supersearch_fields_%s' % namespace
fields = cache.get(cache_key)
if fields is None:
# This needs to be imported in runtime because otherwise you'll
# get a circular import.
from crashstats.supersearch.models import SuperSearchFields
all = SuperSearchFields().get()
fields = []
if baseline:
if isinstance(baseline, tuple):
baseline = list(baseline)
fields.extend(baseline)
for meta in all.itervalues():
if (
meta['namespace'] == namespace and
not meta['permissions_needed'] and
meta['is_returned']
):
if meta['in_database_name'] not in fields:
fields.append(meta['in_database_name'])
fields = tuple(fields)
# Cache for 1 hour.
cache.set(cache_key, fields, 60 * 60)
return fields
示例2: get_from_es
# 需要导入模块: from crashstats.supersearch.models import SuperSearchFields [as 别名]
# 或者: from crashstats.supersearch.models.SuperSearchFields import itervalues [as 别名]
def get_from_es(namespace, baseline=None):
# @namespace is something like 'raw_crash' or 'processed_crash'
fields = cache.get("api_supersearch_fields_%s" % namespace)
if fields is None:
# This needs to be imported in runtime because otherwise you'll
# get a circular import.
from crashstats.supersearch.models import SuperSearchFields
all = SuperSearchFields().get()
fields = []
if baseline:
if isinstance(baseline, tuple):
baseline = list(baseline)
fields.extend(baseline)
for meta in all.itervalues():
if meta["namespace"] == namespace and not meta["permissions_needed"] and meta["is_returned"]:
if meta["in_database_name"] not in fields:
fields.append(meta["in_database_name"])
fields = tuple(fields)
return fields