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(datestring, 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=(), 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 resumtion token is defined.

class ListIdentifiers(extra=None, only=(), 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=(), 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=(), 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=(), 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=(), 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=(), 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=(), 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=(), 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=(), 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=(), 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

OAI-PMH 2.0 response generator.

invenio_oaiserver.response.envelope(**kwargs)[source]

Create OAI-PMH envelope for response.

invenio_oaiserver.response.error(errors)[source]

Create error element.

invenio_oaiserver.response.getrecord(**kwargs)[source]

Create OAI-PMH response for verb Identify.

invenio_oaiserver.response.header(parent, identifier, datestamp, sets=None, deleted=False)[source]

Attach <header/> element to a parent.

invenio_oaiserver.response.identify(**kwargs)[source]

Create OAI-PMH response for verb Identify.

invenio_oaiserver.response.listidentifiers(**kwargs)[source]

Create OAI-PMH response for verb ListIdentifiers.

invenio_oaiserver.response.listmetadataformats(**kwargs)[source]

Create OAI-PMH response for ListMetadataFormats verb.

invenio_oaiserver.response.listrecords(**kwargs)[source]

Create OAI-PMH response for verb ListRecords.

invenio_oaiserver.response.listsets(**kwargs)[source]

Create OAI-PMH response for ListSets verb.

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

Attach resumption token element to a parent.

invenio_oaiserver.response.verb(**kwargs)[source]

Create OAI-PMH envelope for response with verb.

Query parser.

class invenio_oaiserver.query.OAIServerSearch(**kwargs)[source]

Define default filter for quering OAI server.

Use Meta to set kwargs defaults.

class Meta[source]

Configuration for OAI server search.

invenio_oaiserver.query.get_affected_records(spec=None, search_pattern=None)[source]

Get list of affected records.

Parameters:
  • spec – The record spec.
  • search_pattern – The search pattern.
Returns:

An iterator to lazily find results.

invenio_oaiserver.query.get_records(**kwargs)[source]

Get records paginated.

invenio_oaiserver.query.query_string_parser(search_pattern)[source]

Elasticsearch query string parser.

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=(), 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 resumtion 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.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.