API Docs

Invenio-OAIServer extension implementation.

class invenio_oaiserver.ext.InvenioOAIServer(app=None, **kwargs)[source]

Invenio-OAIServer extension.

Extension initialization.

Parameters:app – An instance of flask.Flask. (Default: None)
init_app(app, **kwargs)[source]

Flask application initialization.

Parameters:app – An instance of flask.Flask.
init_config(app)[source]

Initialize configuration.

Parameters:app – An instance of flask.Flask.

Models

Models for storing information about OAIServer state.

class invenio_oaiserver.models.OAISet(**kwargs)[source]

Information about OAI set.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

add_record(record)[source]

Add a record to the OAISet.

Parameters:record (invenio_records.api.Record or derivative.) – Record to be added.
description

Human readable description.

has_record(record)[source]

Check if the record blongs to the OAISet.

Parameters:record (invenio_records.api.Record or derivative.) – Record to be checked.
name

Human readable name of the set.

remove_record(record)[source]

Remove a record from the OAISet.

Parameters:record (invenio_records.api.Record or derivative.) – Record to be removed.
search_pattern

Search pattern to get records.

spec

Set identifier.

validate_spec(key, value)[source]

Forbit updates of set identifier.

Views

Views init.

OAI-PMH verbs.

class invenio_oaiserver.verbs.DateTime(format=None, **kwargs)[source]

DateTime with a permissive deserializer.

from_iso_permissive(use_dateutil=True)[source]

Parse an ISO8601-formatted datetime and return a datetime object.

Inspired by the marshmallow.utils.from_iso function, but also accepts datestrings that don’t contain the time.

class invenio_oaiserver.verbs.OAISchema(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Base OAI argument schema.

class Meta[source]

Schema configuration.

validate(data)[source]

Check range between dates under keys from_ and until.

class invenio_oaiserver.verbs.ResumptionVerbs[source]

List valid verbs when resumption token is defined.

class ListIdentifiers(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for ListIdentifiers verb.

class ListRecords(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for ListRecords verb.

class ListSets(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for ListSets verb.

class invenio_oaiserver.verbs.Verbs[source]

List valid verbs and its arguments.

class GetMetadata(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for GetMetadata verb.

class GetRecord(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for GetRecord verb.

class Identify(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for Identify verb.

class ListIdentifiers(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for ListIdentifiers verb.

class ListMetadataFormats(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for ListMetadataFormats verb.

class ListRecords(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for ListRecords verb.

class ListSets(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Arguments for ListSets verb.

invenio_oaiserver.verbs.make_request_validator(request)[source]

Validate arguments in incomming request.

invenio_oaiserver.verbs.validate_metadata_prefix(value)[source]

Check metadataPrefix.

Parameters:value – One of the metadata identifiers configured in OAISERVER_METADATA_FORMATS.

Response

Implement funtions for managing OAI-PMH resumption token.

class invenio_oaiserver.resumption_token.ResumptionToken(default=<marshmallow.missing>, attribute=None, load_from=None, dump_to=None, error=None, validate=None, required=False, allow_none=None, load_only=False, dump_only=False, missing=<marshmallow.missing>, error_messages=None, **metadata)[source]

Resumption token validator.

class invenio_oaiserver.resumption_token.ResumptionTokenSchema(extra=None, only=None, exclude=(), prefix=u'', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)[source]

Schema with resumption token.

load(data, many=None, partial=None)[source]

Deserialize a data structure to an object.

invenio_oaiserver.resumption_token.serialize(pagination, **kwargs)[source]

Return resumption token serializer.

Persistent identifier

OAI-PMH ID provider.

class invenio_oaiserver.provider.OAIIDProvider(pid)[source]

OAI-PMH identifier provider.

Initialize provider using persistent identifier.

Parameters:pid – A invenio_pidstore.models.PersistentIdentifier instance.
classmethod create(object_type=None, object_uuid=None, **kwargs)[source]

Create a new record identifier.

Parameters:
  • object_type – The object type. (Default: None)
  • object_uuid – The object UUID. (Default: None)
default_status = 'K'

OAI IDs are by default registered when object is known.

pid_provider = 'oai'

Provider name.

pid_type = 'oai'

Type of persistent identifier.

Persistent identifier minters.

invenio_oaiserver.minters.oaiid_minter(record_uuid, data)[source]

Mint record identifiers.

Parameters:
  • record_uuid – The record UUID.
  • data – The record data.
Returns:

A invenio_pidstore.models.PersistentIdentifier instance.

Persistent identifier fetchers.

invenio_oaiserver.fetchers.oaiid_fetcher(record_uuid, data)[source]

Fetch a record’s identifier.

Parameters:
  • record_uuid – The record UUID.
  • data – The record data.
Returns:

A invenio_pidstore.fetchers.FetchedPID instance.

Utilities

Utilities.

invenio_oaiserver.utils.datetime_to_datestamp(dt, day_granularity=False)[source]

Transform datetime to datestamp.

Parameters:
  • dt – The datetime to convert.
  • day_granularity – Set day granularity on datestamp.
Returns:

The datestamp.

invenio_oaiserver.utils.dumps_etree(pid, record, **kwargs)[source]

Dump MARC21 compatible record.

Parameters:
Returns:

A LXML Element instance.

invenio_oaiserver.utils.eprints_description(metadataPolicy, dataPolicy, submissionPolicy=None, content=None)[source]

Generate the eprints element for the identify response.

The eprints container is used by the e-print community to describe the content and policies of repositories. For the full specification and schema definition visit: http://www.openarchives.org/OAI/2.0/guidelines-eprints.htm

invenio_oaiserver.utils.friends_description(baseURLs)[source]

Generate the friends element for the identify response.

The friends container is recommended for use by repositories to list confederate repositories. For the schema definition visit: http://www.openarchives.org/OAI/2.0/guidelines-friends.htm

invenio_oaiserver.utils.oai_identifier_description(scheme, repositoryIdentifier, delimiter, sampleIdentifier)[source]

Generate the oai-identifier element for the identify response.

The OAI identifier format is intended to provide persistent resource identifiers for items in repositories that implement OAI-PMH. For the full specification and schema definition visit: http://www.openarchives.org/OAI/2.0/guidelines-oai-identifier.htm

invenio_oaiserver.utils.sanitize_unicode(value)[source]

Removes characters incompatible with XML1.0.

Following W3C recommandation : https://www.w3.org/TR/REC-xml/#charsets Based on https://lsimons.wordpress.com/2011/03/17/stripping-illegal-characters-out-of-xml-in-python/ # noqa

invenio_oaiserver.utils.serializer(*args, **kwds)[source]

Return etree_dumper instances.

Parameters:metadata_prefix – One of the metadata identifiers configured in OAISERVER_METADATA_FORMATS.

Error.

exception invenio_oaiserver.errors.OAIBadMetadataFormatError[source]

Metadata format required doesn’t exist.

exception invenio_oaiserver.errors.OAISetSpecUpdateError[source]

Spec attribute cannot be updated.

The correct way is to delete the set and create a new one.