Redirector

Init.

Model

GoTo database models.

class invenio.modules.redirector.models.Goto(**kwargs)

Represents a Goto record.

to_dict()

Return a dict representation of Goto.

validate_plugin(key, plugin)

Validate plugin name.

API

Redirecting engine.

invenio.modules.redirector.api.drop_redirection(label)

Delete an existing redirection identified by label.

Parameters:label (string) – the uniquely identifying label for this redirection
invenio.modules.redirector.api.get_redirection_data(label)

Return all information about a given redirection identified by label.

Parameters:label (string) – the label identifying the redirection
Returns:a dictionary with the following keys: * label: the label * plugin: the name of the plugin * parameters: the parameters that are passed to the plugin (deserialized from JSON) * creation_date: datetime object on when the redirection was first created. * modification_date: datetime object on when the redirection was last modified.
Return type:dict
Raises:NoResultFound in case the label does not exist.
invenio.modules.redirector.api.register_redirection(label, plugin, parameters=None, update_on_duplicate=False)

Register a redirection from /goto/<LABEL> to the URL.

Register a redirection from /goto/<LABEL> to the URL returned by running the given plugin (as available in REDIRECT_METHODS), with the given parameters.

Parameters:
  • label (string) – the uniquely identifying label for this redirection
  • plugin (string) – the algorithm that should resolve the redirection, usually: “goto_plugin_FOO”
  • parameters (dict) – further parameters that should be passed to the plugin. This should be a dictionary or None. Note that these parameters could be overridden by the query parameters.
  • update_on_duplicate (bool) – if False (default), if the label already exist it L{register_redirection} will raise a ValueError exception. If True, it will implicitly call L{update_redirection}.
Raises:

NoResultFound in case not exist and L{update_on_duplicate} is set to False.

Note:

parameters are going to be serialized to JSON before being stored in the DB. Hence only JSON-serializable values should be put there.

invenio.modules.redirector.api.update_redirection(label, plugin, parameters=None)

Update an existing redirection from /goto/<LABEL> to the URL.

Update an existing redirection from /goto/<LABEL> to the URL returned by running the given plugin (as available in REDIRECT_METHODS), with the given parameters.

Parameters:
  • label (string) – the uniquely identifying label for this redirection
  • plugin (string) – the algorithm that should resolve the redirection, usually: “goto_plugin_FOO”
  • parameters (dict) – further parameters that should be passed to the plugin. This should be a dictionary or None. Note that these parameters could be overridden by the query parameters.
Raises:

NoResultFound in case the label does not already exist.

Note:

parameters are going to be serialized to JSON before being stored in the DB. Hence only JSON-serializable values should be put there.

Manage

Manage redirector module.

invenio.modules.redirector.manage.create(label, plugin, parameters, update_redirection=False)

Register redirection page.

invenio.modules.redirector.manage.delete(label)

Delete an existing redirection.

invenio.modules.redirector.manage.list()

Get a list of available plugins.

invenio.modules.redirector.manage.main()

Execute script.

invenio.modules.redirector.manage.read(label)

Return all information about an redirection.

invenio.modules.redirector.manage.update(label, plugin, parameters=None)

Update an existing redirection.