API Docs¶
Invenio module with nice defaults for MARC21 overlay.
-
class
invenio_marc21.ext.
InvenioMARC21
(app=None)[source]¶ Invenio-MARC21 extension.
Extension initialization.
Parameters: app – An instance of flask.Flask
.-
init_app
(app)[source]¶ Flask application initialization.
Parameters: app – An instance of flask.Flask
.
-
init_config
(app)[source]¶ Initialize configuration.
Parameters: app – An instance of flask.Flask
.
-
Serializers¶
Base class for dojson based serializers.
-
class
invenio_marc21.serializers.dojson.
DoJSONSerializer
(dojson_model, replace_refs=False)[source]¶ Base class for marshmallow serializers.
Initialize serializer.
Parameters: - dojson_model – The DoJSON model able to convert JSON through the
do()
function. - replace_refs – Boolean value to configure if the
$ref
keys are replaced. (Default:False
)
-
dump
(obj)[source]¶ Serialize object with schema.
Parameters: obj – The object to serialize. Returns: The object serialized.
-
transform_record
(pid, record, links_factory=None)[source]¶ Transform record into an intermediate representation.
Parameters: - pid – The
invenio_pidstore.models.PersistentIdentifier
instance. - record – The
invenio_records.api.Record
instance. - links_factory – The link factory. (Default:
None
)
Returns: The intermediate representation for the record.
- pid – The
-
transform_search_hit
(pid, record_hit, links_factory=None)[source]¶ Transform search result hit into an intermediate representation.
Parameters: - pid – The
invenio_pidstore.models.PersistentIdentifier
instance. - record_hit – A dictionary containing a
'_source'
key with the record data. - links_factory – The link factory. (Default:
None
)
Returns: The intermediate representation for the record.
- pid – The
- dojson_model – The DoJSON model able to convert JSON through the
MARC21 based serializer.
-
class
invenio_marc21.serializers.marcxml.
MARCXMLSerializer
(dojson_model, xslt_filename=None, schema_class=None, replace_refs=False)[source]¶ DoJSON based MARCXML serializer for records.
Note: This serializer is not suitable for serializing large number of records due to high memory usage.
Initialize serializer.
Parameters: - dojson_model – The DoJSON model able to convert JSON through the
do()
function. - xslt_filename – XSLT filename. (Default:
None
) - schema_class – The schema class. (Default:
None
) - replace_refs – Boolean value to configure if replace the
$ref
keys within the JSON. (Default:False
)
-
dump
(obj)[source]¶ Serialize object with schema.
Parameters: obj – The object to serialize. Returns: The object serialized.
-
serialize
(pid, record, links_factory=None)[source]¶ Serialize a single record and persistent identifier.
Parameters: - pid – The
invenio_pidstore.models.PersistentIdentifier
instance. - record – The
invenio_records.api.Record
instance. - links_factory – Factory function for the link generation, which are added to the response.
Returns: The object serialized.
- pid – The
-
serialize_oaipmh
(pid, record)[source]¶ Serialize a single record for OAI-PMH.
Parameters: - pid – The
invenio_pidstore.models.PersistentIdentifier
instance. - record – The
invenio_records.api.Record
instance.
Returns: The object serialized.
- pid – The
-
serialize_search
(pid_fetcher, search_result, item_links_factory=None, **kwargs)[source]¶ Serialize a search result.
Parameters: - pid_fetcher – Persistent identifier fetcher.
- search_result – Elasticsearch search result.
- item_links_factory – Factory function for the items in result.
(Default:
None
)
Returns: The objects serialized.
- dojson_model – The DoJSON model able to convert JSON through the