本文整理汇总了Python中ckan.lib.search.index.PackageSearchIndex.commit方法的典型用法代码示例。如果您正苦于以下问题:Python PackageSearchIndex.commit方法的具体用法?Python PackageSearchIndex.commit怎么用?Python PackageSearchIndex.commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ckan.lib.search.index.PackageSearchIndex
的用法示例。
在下文中一共展示了PackageSearchIndex.commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: harvest_sources_reindex
# 需要导入模块: from ckan.lib.search.index import PackageSearchIndex [as 别名]
# 或者: from ckan.lib.search.index.PackageSearchIndex import commit [as 别名]
def harvest_sources_reindex(context, data_dict):
"""
Reindexes all harvest source datasets with the latest status
"""
log.info("Reindexing all harvest sources")
check_access("harvest_sources_reindex", context, data_dict)
model = context["model"]
packages = (
model.Session.query(model.Package)
.filter(model.Package.type == DATASET_TYPE_NAME)
.filter(model.Package.state == u"active")
.all()
)
package_index = PackageSearchIndex()
for package in packages:
if "extras_as_string" in context:
del context["extras_as_string"]
context.update({"validate": False, "ignore_auth": True})
package_dict = logic.get_action("package_show")(context, {"id": package.id})
log.debug("Updating search index for harvest source {0}".format(package.id))
package_index.index_package(package_dict, defer_commit=True)
package_index.commit()
log.info("Updated search index for {0} harvest sources".format(len(packages)))
示例2: harvest_sources_reindex
# 需要导入模块: from ckan.lib.search.index import PackageSearchIndex [as 别名]
# 或者: from ckan.lib.search.index.PackageSearchIndex import commit [as 别名]
def harvest_sources_reindex(context, data_dict):
"""
Reindexes all harvest source datasets with the latest status
"""
log.info("Reindexing all harvest sources")
check_access("harvest_sources_reindex", context, data_dict)
model = context["model"]
packages = (
model.Session.query(model.Package)
.filter(model.Package.type == DATASET_TYPE_NAME)
.filter(model.Package.state == u"active")
.all()
)
package_index = PackageSearchIndex()
reindex_context = {"defer_commit": True}
for package in packages:
get_action("harvest_source_reindex")(reindex_context, {"id": package.id})
package_index.commit()
return True
示例3: harvest_sources_reindex
# 需要导入模块: from ckan.lib.search.index import PackageSearchIndex [as 别名]
# 或者: from ckan.lib.search.index.PackageSearchIndex import commit [as 别名]
def harvest_sources_reindex(context, data_dict):
'''
Reindexes all harvest source datasets with the latest status
'''
log.info('Reindexing all harvest sources')
check_access('harvest_sources_reindex', context, data_dict)
model = context['model']
packages = model.Session.query(model.Package) \
.filter(model.Package.type==DATASET_TYPE_NAME) \
.filter(model.Package.state==u'active') \
.all()
package_index = PackageSearchIndex()
for package in packages:
if 'extras_as_string'in context:
del context['extras_as_string']
context.update({'ignore_auth': True})
package_dict = logic.get_action('harvest_source_show')(context,
{'id': package.id})
log.debug('Updating search index for harvest source {0}'.format(package.id))
package_index.index_package(package_dict, defer_commit=True)
package_index.commit()
log.info('Updated search index for {0} harvest sources'.format(len(packages)))
示例4: harvest_sources_reindex
# 需要导入模块: from ckan.lib.search.index import PackageSearchIndex [as 别名]
# 或者: from ckan.lib.search.index.PackageSearchIndex import commit [as 别名]
def harvest_sources_reindex(context, data_dict):
'''
Reindexes all harvest source datasets with the latest status
'''
log.info('Reindexing all harvest sources')
check_access('harvest_sources_reindex', context, data_dict)
model = context['model']
packages = model.Session.query(model.Package) \
.filter(model.Package.type==DATASET_TYPE_NAME) \
.filter(model.Package.state==u'active') \
.all()
package_index = PackageSearchIndex()
reindex_context = {'defer_commit': True}
for package in packages:
get_action('harvest_source_reindex')(reindex_context, {'id': package.id})
package_index.commit()
return True