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.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.

OAISchema.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 ResumptionVerbs.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 ResumptionVerbs.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 Verbs.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 Verbs.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 Verbs.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 Verbs.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 Verbs.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 Verbs.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.

Admin model views for OAI sets.

class invenio_oaiserver.admin.OAISetModelView(model, session, name=None, category=None, endpoint=None, url=None, static_folder=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]

OAISets model view.

Constructor.

Parameters:
  • model – Model class
  • session – SQLAlchemy session
  • name – View name. If not set, defaults to the model name
  • category – Category name
  • endpoint – Endpoint name. If not set, defaults to the model name
  • url – Base URL. If not set, defaults to ‘/admin/’ + endpoint
  • menu_class_name – Optional class name for the menu item.
  • menu_icon_type

    Optional icon. Possible icon types:

    • flask_admin.consts.ICON_TYPE_GLYPH - Bootstrap glyph icon
    • flask_admin.consts.ICON_TYPE_FONT_AWESOME - Font Awesome icon
    • flask_admin.consts.ICON_TYPE_IMAGE - Image relative to Flask static directory
    • flask_admin.consts.ICON_TYPE_IMAGE_URL - Image with full URL
  • menu_icon_value – Icon glyph name or URL, depending on menu_icon_type setting
action_view(*args, **kwargs)

Mass-model action view.

ajax_update(*args, **kwargs)

Edits a single column of a record in list view.

create_view(*args, **kwargs)

Create model view

delete_view(*args, **kwargs)

Delete model view. Only POST method is allowed.

details_view(*args, **kwargs)

Details model view

edit_form(obj)[source]

Customize edit form.

edit_view(*args, **kwargs)

Edit model view

index_view(*args, **kwargs)

List view

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.

class invenio_oaiserver.query.Query(query=None)[source]

Query object.

Parse query string using given grammar.

Parameters:query – The query to parse. (Default: None)
match(record)[source]

Return True if record match the query.

Parameters:record – The record in which to look for matches.
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 recordsi paginated.

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.parser()[source]

Return search query parser.

invenio_oaiserver.utils.query_walkers()[source]

Return query walker instances.

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.