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.
-
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
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
-
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
-
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_view
(*args, **kwargs)¶ Edit model view
-
index_view
(*args, **kwargs)¶ List view
Response¶
OAI-PMH 2.0 response generator.
-
invenio_oaiserver.response.
header
(parent, identifier, datestamp, sets=None, deleted=False)[source]¶ Attach
<header/>
element to a parent.
-
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.
resumption_token
(parent, pagination, **kwargs)[source]¶ Attach resumption token element to a parent.
Query parser.
-
class
invenio_oaiserver.query.
OAIServerSearch
(**kwargs)[source]¶ Define default filter for quering OAI server.
Use Meta to set kwargs defaults.
-
class
invenio_oaiserver.query.
Query
(query=None)[source]¶ Query object.
Parse query string using given grammar.
Parameters: query – The query to parse. (Default: None
)
-
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.
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.
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
)
- object_type – The object type. (Default:
-
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.
-
classmethod
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: - pid – The
invenio_pidstore.models.PersistentIdentifier
instance. - record – The
invenio_records.api.Record
instance.
Returns: A LXML Element instance.
- pid – The
-
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.