當前位置: 首頁>>代碼示例>>Python>>正文


Python X.request方法代碼示例

本文整理匯總了Python中invenio.htmlutils.X.request方法的典型用法代碼示例。如果您正苦於以下問題:Python X.request方法的具體用法?Python X.request怎麽用?Python X.request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在invenio.htmlutils.X的用法示例。


在下文中一共展示了X.request方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: oai_error

# 需要導入模塊: from invenio.htmlutils import X [as 別名]
# 或者: from invenio.htmlutils.X import request [as 別名]
def oai_error(argd, errors):
    """
    Return a well-formatted OAI-PMH error
    """
    out = """<?xml version="1.0" encoding="UTF-8"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
         http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">"""
    out += X.responseDate()(get_utc_now())
    for error_code, error_msg in errors:
        assert(error_code in CFG_ERRORS)
        if error_code in ("badArgument", "badVerb"):
            out += X.request()(oai_get_request_url())
            break
    else:
        ## There are no badArgument or badVerb errors so we can
        ## return the whole request information
        out += X.request(**argd)(oai_get_request_url())
    for error_code, error_msg in errors:
        if error_msg is None:
            error_msg = CFG_ERRORS[error_code]
        else:
            error_msg = "%s %s" % (CFG_ERRORS[error_code], error_msg)
        out += X.error(code=error_code)(error_msg)
    out += "</OAI-PMH>"
    return out
開發者ID:peskk3am,項目名稱:b2share,代碼行數:29,代碼來源:oai_repository_server.py

示例2: oai_build_request_element

# 需要導入模塊: from invenio.htmlutils import X [as 別名]
# 或者: from invenio.htmlutils.X import request [as 別名]
def oai_build_request_element(argd=None):
    """
    Build the request tag.
    """
    if argd is None:
        argd = {}
    return X.responseDate()(get_utc_now()) + X.request(**argd)("%s/oai2d" % CFG_SITE_SECURE_URL or CFG_SITE_URL)
開發者ID:peskk3am,項目名稱:b2share,代碼行數:9,代碼來源:oai_repository_server.py

示例3: oai_header

# 需要導入模塊: from invenio.htmlutils import X [as 別名]
# 或者: from invenio.htmlutils.X import request [as 別名]
def oai_header(argd, verb):
    """
    Return OAI header
    """

    out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n"
    out += "<?xml-stylesheet type=\"text/xsl\" href=\"%s/css/oai2.xsl.v1.0\" ?>\n" % CFG_SITE_SECURE_URL or CFG_SITE_URL
    out += "<OAI-PMH xmlns=\"http://www.openarchives.org/OAI/2.0/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd\">\n"

    #out += "<responseDate>%s</responseDate>" % get_utc_now()
    out += X.responseDate()(get_utc_now())

    if verb:
        out += X.request(**argd)(oai_get_request_url())
        out += "<%s>\n" % verb
    else:
        out += X.request()(oai_get_request_url())

    return out
開發者ID:peskk3am,項目名稱:b2share,代碼行數:21,代碼來源:oai_repository_server.py


注:本文中的invenio.htmlutils.X.request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。