Ejemplo n.º 1
0
def oai_identify(argd):
    """Generates a response to oai_identify verb.

     script_url - *str* URL of the script used to access the
                  service. This is made necessary since the gateway
                  can be accessed either via /oai2d or /oai2d/ (or for
                  backward compatibility: oai2d.py or oai2d.py/), and
                  that the base URL must be returned in the Identify
                  response
    """

    out = X.repositoryName()(CFG_SITE_NAME)
    out += X.baseURL()(CFG_SITE_URL + '/oai2d')
    out += X.protocolVersion()("2.0")
    out += X.adminEmail()(CFG_SITE_SUPPORT_EMAIL)
    out += X.earliestDatestamp()(get_earliest_datestamp())
    out += X.deletedRecord()(CFG_OAI_DELETED_POLICY)
    out += X.granularity()("YYYY-MM-DDThh:mm:ssZ")
    if CFG_WEBSTYLE_HTTP_USE_COMPRESSION:
        out += X.compression()('deflate')
    out += X.description(
        """<oai-identifier xmlns="http://www.openarchives.org/OAI/2.0/oai-identifier"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai-identifier
                                       http://www.openarchives.org/OAI/2.0/oai-identifier.xsd">"""
        + X.scheme()("oai") + X.repositoryIdentifier()(CFG_OAI_ID_PREFIX) +
        X.delimiter()(":") + X.sampleIdentifier()(CFG_OAI_SAMPLE_IDENTIFIER) +
        """</oai-identifier>""")
    out += CFG_OAI_IDENTIFY_DESCRIPTION % {
        'CFG_SITE_URL': EscapedXMLString(CFG_SITE_URL)
    }
    if CFG_OAI_FRIENDS:
        friends = """<friends xmlns="http://www.openarchives.org/OAI/2.0/friends/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/friends/
      http://www.openarchives.org/OAI/2.0/friends.xsd">"""
        for baseurl in CFG_OAI_FRIENDS:
            friends += X.baseURL()(baseurl)
        friends += """</friends>"""
        out += X.description(friends)

    out = oai_header(argd, "Identify") + out + oai_footer("Identify")

    return out
Ejemplo n.º 2
0
def oai_identify(argd):
    """Generates a response to oai_identify verb.

     script_url - *str* URL of the script used to access the
                  service. This is made necessary since the gateway
                  can be accessed either via /oai2d or /oai2d/ (or for
                  backward compatibility: oai2d.py or oai2d.py/), and
                  that the base URL must be returned in the Identify
                  response
    """

    out = X.repositoryName()(CFG_SITE_NAME)
    out += X.baseURL()((CFG_SITE_SECURE_URL or CFG_SITE_URL) + '/oai2d')
    out += X.protocolVersion()("2.0")
    out += X.adminEmail()(CFG_SITE_SUPPORT_EMAIL)
    out += X.earliestDatestamp()(get_earliest_datestamp())
    out += X.deletedRecord()(CFG_OAI_DELETED_POLICY)
    out += X.granularity()("YYYY-MM-DDThh:mm:ssZ")
    if CFG_WEBSTYLE_HTTP_USE_COMPRESSION:
        out += X.compression()('deflate')
    out += X.description("""<oai-identifier xmlns="http://www.openarchives.org/OAI/2.0/oai-identifier"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai-identifier
                                       http://www.openarchives.org/OAI/2.0/oai-identifier.xsd">""" +
                X.scheme()("oai") +
                X.repositoryIdentifier()(CFG_OAI_ID_PREFIX) +
                X.delimiter()(":") +
                X.sampleIdentifier()(CFG_OAI_SAMPLE_IDENTIFIER) +
                """</oai-identifier>""")
    out += CFG_OAI_IDENTIFY_DESCRIPTION % {'CFG_SITE_URL': EscapedXMLString(CFG_SITE_SECURE_URL or CFG_SITE_URL)}
    if CFG_OAI_FRIENDS:
        friends = """<friends xmlns="http://www.openarchives.org/OAI/2.0/friends/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/friends/
      http://www.openarchives.org/OAI/2.0/friends.xsd">"""
        for baseurl in CFG_OAI_FRIENDS:
            friends += X.baseURL()(baseurl)
        friends += """</friends>"""
        out += X.description(friends)

    out = oai_header(argd, "Identify") + out + oai_footer("Identify")

    return out
Ejemplo n.º 3
0
def get_record_provenance(recid):
    """
    Return the provenance XML representation of a record, suitable to be put
    in the about tag.
    """
    record = get_record(recid)
    provenances = record_get_field_instances(
        record, CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3],
        CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3],
        CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4])
    out = ""
    for provenance in provenances:
        base_url = identifier = datestamp = metadata_namespace = origin_description = harvest_date = altered = ""
        for (code, value) in provenance[0]:
            if code == CFG_OAI_PROVENANCE_BASEURL_SUBFIELD:
                base_url = value
            elif code == CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[5]:
                identifier = value
            elif code == CFG_OAI_PROVENANCE_DATESTAMP_SUBFIELD:
                datestamp = value
            elif code == CFG_OAI_PROVENANCE_METADATANAMESPACE_SUBFIELD:
                metadata_namespace = value
            elif code == CFG_OAI_PROVENANCE_ORIGINDESCRIPTION_SUBFIELD:
                origin_description = value
            elif code == CFG_OAI_PROVENANCE_HARVESTDATE_SUBFIELD:
                harvest_date = value
            elif code == CFG_OAI_PROVENANCE_ALTERED_SUBFIELD:
                altered = value
        if base_url:
            out += """<provenance xmlns="http://www.openarchives.org/OAI/2.0/provenance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/provenance http://www.openarchives.org/OAI/2.0/provenance.xsd">"""
            out += X.originDescription(
                harvestDate=harvest_date, altered=altered)(
                    X.baseURL()(base_url),
                    X.identifier()(identifier),
                    X.datestamp()(datestamp),
                    X.metadataNamespace()(metadata_namespace),
                    origin_description
                    and X.originDescription(origin_description)
                    or ''  ## This is already XML
                )
            out += """</provenance>"""
    return out
Ejemplo n.º 4
0
def get_record_provenance(recid):
    """
    Return the provenance XML representation of a record, suitable to be put
    in the about tag.
    """
    record = get_record(recid)
    provenances = record_get_field_instances(record, CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[:3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[3], CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[4])
    out = ""
    for provenance in provenances:
        base_url = identifier = datestamp = metadata_namespace = origin_description = harvest_date = altered = ""
        for (code, value) in provenance[0]:
            if code == CFG_OAI_PROVENANCE_BASEURL_SUBFIELD:
                base_url = value
            elif code == CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG[5]:
                identifier = value
            elif code == CFG_OAI_PROVENANCE_DATESTAMP_SUBFIELD:
                datestamp = value
            elif code == CFG_OAI_PROVENANCE_METADATANAMESPACE_SUBFIELD:
                metadata_namespace = value
            elif code == CFG_OAI_PROVENANCE_ORIGINDESCRIPTION_SUBFIELD:
                origin_description = value
            elif code == CFG_OAI_PROVENANCE_HARVESTDATE_SUBFIELD:
                harvest_date = value
            elif code == CFG_OAI_PROVENANCE_ALTERED_SUBFIELD:
                altered = value
        if base_url:
            out += """<provenance xmlns="http://www.openarchives.org/OAI/2.0/provenance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/provenance http://www.openarchives.org/OAI/2.0/provenance.xsd">"""
            out += X.originDescription(harvestDate=harvest_date, altered=altered)(
                X.baseURL()(base_url),
                X.identifier()(identifier),
                X.datestamp()(datestamp),
                X.metadataNamespace()(metadata_namespace),
                origin_description and X.originDescription(origin_description) or '' ## This is already XML
            )
            out += """</provenance>"""
    return out