当前位置: 首页>>代码示例>>Python>>正文


Python PackageSearchIndex.commit方法代码示例

本文整理汇总了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)))
开发者ID:kata-csc,项目名称:ckanext-harvest,代码行数:29,代码来源:update.py

示例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
开发者ID:waldvogel,项目名称:ckanext-harvest,代码行数:27,代码来源:update.py

示例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)))
开发者ID:poguez,项目名称:ckanext-harvest,代码行数:28,代码来源:update.py

示例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
开发者ID:CDECatapult,项目名称:edx-ckanext-harvest,代码行数:25,代码来源:update.py


注:本文中的ckan.lib.search.index.PackageSearchIndex.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。