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


Python X.resumptionToken方法代码示例

本文整理汇总了Python中invenio.htmlutils.X.resumptionToken方法的典型用法代码示例。如果您正苦于以下问题:Python X.resumptionToken方法的具体用法?Python X.resumptionToken怎么用?Python X.resumptionToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invenio.htmlutils.X的用法示例。


在下文中一共展示了X.resumptionToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: oai_list_records_or_identifiers

# 需要导入模块: from invenio.htmlutils import X [as 别名]
# 或者: from invenio.htmlutils.X import resumptionToken [as 别名]
def oai_list_records_or_identifiers(req, argd):
    """Generates response to oai_list_records verb."""

    verb = argd['verb']
    resumption_token_was_specified = False

    # check if the resumption_token did not expire
    if argd.get('resumptionToken'):
        resumption_token_was_specified = True
        try:
            cache = oai_cache_load(argd['resumptionToken'])
            last_recid = cache['last_recid']
            argd = cache['argd']
            complete_list = cache['complete_list']
            complete_list = filter_out_based_on_date_range(complete_list, argd.get('from', ''), argd.get('until', ''))
        except Exception:
            register_exception(alert_admin=True)
            req.write(oai_error(argd, [("badResumptionToken", "ResumptionToken expired or invalid: %s" % argd['resumptionToken'])]))
            return
    else:
        last_recid = 0
        complete_list = oai_get_recid_list(argd.get('set', ""), argd.get('from', ""), argd.get('until', ""))

        if not complete_list: # noRecordsMatch error
            req.write(oai_error(argd, [("noRecordsMatch", "no records correspond to the request")]))
            return

    cursor = 0
    for cursor, recid in enumerate(complete_list):
        ## Let's fast-forward the cursor to point after the last recid that was
        ## disseminated successfully
        if recid > last_recid:
            break

    set_last_updated = get_set_last_update(argd.get('set', ""))

    req.write(oai_header(argd, verb))
    for recid in list(complete_list)[cursor:cursor+CFG_OAI_LOAD]:
        req.write(print_record(recid, argd['metadataPrefix'], verb=verb, set_spec=argd.get('set'), set_last_updated=set_last_updated))

    if list(complete_list)[cursor+CFG_OAI_LOAD:]:
        resumption_token = oai_generate_resumption_token(argd.get('set', ''))
        cache = {
            'argd': argd,
            'last_recid': recid,
            'complete_list': complete_list.fastdump(),
        }
        oai_cache_dump(resumption_token, cache)
        expdate = oai_get_response_date(CFG_OAI_EXPIRE)
        req.write(X.resumptionToken(expirationDate=expdate, cursor=cursor, completeListSize=len(complete_list))(resumption_token))
    elif resumption_token_was_specified:
        ## Since a resumptionToken was used we shall put a last empty resumptionToken
        req.write(X.resumptionToken(cursor=cursor, completeListSize=len(complete_list))(""))
    req.write(oai_footer(verb))
    oai_cache_gc()
开发者ID:peskk3am,项目名称:b2share,代码行数:57,代码来源:oai_repository_server.py

示例2: get_set_last_update

# 需要导入模块: from invenio.htmlutils import X [as 别名]
# 或者: from invenio.htmlutils.X import resumptionToken [as 别名]
    set_last_updated = get_set_last_update(argd.get('set', ""))

    req.write(oai_header(argd, verb))
    for recid in list(complete_list)[cursor:cursor+CFG_OAI_LOAD]:
        req.write(print_record(recid, argd['metadataPrefix'], verb=verb, set_spec=argd.get('set'), set_last_updated=set_last_updated))

    if list(complete_list)[cursor+CFG_OAI_LOAD:]:
        resumption_token = oai_generate_resumption_token(argd.get('set', ''))
        cache = {
            'argd': argd,
            'last_recid': recid,
            'complete_list': complete_list.fastdump(),
        }
        oai_cache_dump(resumption_token, cache)
        expdate = oai_get_response_date(CFG_OAI_EXPIRE)
        req.write(X.resumptionToken(expirationDate=expdate, cursor=cursor, completeListSize=len(complete_list))(resumption_token))
    elif resumption_token_was_specified:
        ## Since a resumptionToken was used we shall put a last empty resumptionToken
        req.write(X.resumptionToken(cursor=cursor, completeListSize=len(complete_list))(""))
    req.write(oai_footer(verb))
    oai_cache_gc()

def oai_list_sets(argd):
    """
    Lists available sets for OAI metadata harvesting.
    """

    out = ""

    # note: no flow control in ListSets
    sets = get_all_sets().values()
开发者ID:BessemAamira,项目名称:invenio,代码行数:33,代码来源:oai_repository_server.py


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