API Docs

Flask extension

Flask extension for Invenio-Records-UI.

class invenio_records_ui.ext.InvenioRecordsUI(app=None)[source]

Invenio-Records-UI extension.

The extension takes care of setting default configuration and registering a blueprint with URL routes for the endpoints.

Extension initialization.

Parameters:app – The Flask application. (Default: None)

Flask application initialization.

Parameters:app – The Flask application.

Initialize configuration on application.

Parameters:app – The Flask application.
class invenio_records_ui.ext._RecordUIState(app)[source]

Record UI state.

Initialize state.

Parameters:app – The Flask application.

List of export formats.


Load default permission factory.


Factory for creating a blueprint for Invenio-Records-UI.


Create Invenio-Records-UI blueprint.

The factory installs one URL route per endpoint defined, and adds an error handler for rendering tombstones.

Parameters:endpoints – Dictionary of endpoints to be installed. See usage documentation for further details.
Returns:The initialized blueprint.

Create Invenio-Records-UI blueprint from a Flask application.


This function assumes that the application has loaded all extensions that want to register REST endpoints via the RECORDS_UI_ENDPOINTS configuration variable.

Params app:A Flask application.
Returns:Configured blueprint.
invenio_records_ui.views.create_url_rule(endpoint, route=None, pid_type=None, template=None, permission_factory_imp=None, view_imp=None, record_class=None, methods=None)[source]

Create Werkzeug URL rule for a specific endpoint.

The method takes care of creating a persistent identifier resolver for the given persistent identifier type.

  • endpoint – Name of endpoint.
  • route – URL route (must include <pid_value> pattern). Required.
  • pid_type – Persistent identifier type for endpoint. Required.
  • template – Template to render. (Default: invenio_records_ui/detail.html)
  • permission_factory_imp – Import path to factory that creates a permission object for a given record.
  • view_imp – Import path to view function. (Default: None)
  • record_class – Name of the record API class.
  • methods – Method allowed for the endpoint.

A dictionary that can be passed as keywords arguments to Blueprint.add_url_rule.

invenio_records_ui.views.default_view_method(pid, record, template=None, **kwargs)[source]

Display default view.

Sends record_viewed signal and renders template.

  • pid – PID object.
  • record – Record object.
  • template – Template to render.
  • **kwargs – Additional view arguments based on URL rule.

The rendered template.

invenio_records_ui.views.export(pid, record, template=None, **kwargs)[source]

Record serialization view.

Serializes record with given format and renders record export template.

  • pid – PID object.
  • record – Record object.
  • template – Template to render.
  • **kwargs – Additional view arguments based on URL rule.

The rendered template.

invenio_records_ui.views.record_view(pid_value=None, resolver=None, template=None, permission_factory=None, view_method=None, **kwargs)[source]

Display record view.

The two parameters resolver and template should not be included in the URL rule, but instead set by creating a partially evaluated function of the view.

The template being rendered is passed two variables in the template context:

  • pid
  • record.

Procedure followed:

  1. PID and record are resolved.
  2. Permission are checked.
  3. view_method is called.
  • pid_value – Persistent identifier value.
  • resolver – An instance of a persistent identifier resolver. A persistent identifier resolver takes care of resolving persistent identifiers into internal objects.
  • template – Template to render.
  • permission_factory – Permission factory called to check if user has enough power to execute the action.
  • view_method – Function that is called.

Tuple (pid object, record object).


Record module signals.

invenio_records_ui.signals.record_viewed = <blinker.base.NamedSignal object at 0x7fdd9e1985d0; 'record-viewed'>

Signal sent when a record is viewed on any endpoint.


  • sender - a Flask application object.
  • pid - a persistent identifier instance.
  • record - a record instance.

Example receiver:

def receiver(sender, record=None, pid=None):
    # ...

Note, the signal is always sent in a request context, thus it is safe to access the current request and/or current user objects inside the receiver.