deposit.protocol module

exception deposit.protocol.DepositError[source]

Bases: exceptions.Exception

The exception to raise when something wrong happens during the deposition process

class deposit.protocol.DepositResult(identifier=None, splash_url=None, pdf_url=None, logs=None, status=u'published', message=None)[source]

Bases: object

Small object containing the result of a deposition process. This object will be stored in two rows in the database: in a BareOaiRecord and in a DepositRecord.

status should be one of DEPOSIT_STATUS_CHOICES

class deposit.protocol.RepositoryProtocol(repository, **kwargs)[source]

Bases: object

The protocol for a repository where papers can be deposited. Actual implementations should inherit from this class.


alias of BaseMetadataForm


Returns a bound version of the form, with the given data. Here, data is expected to come from a POST request generated by the user, ready for validation.


Returns the form where the user will be able to give additional metadata. It is prefilled with the initial data from get_form_initial_data


Returns the form’s initial values.


Returns an instance of the preferences for a user. If the preferences already exist, they will be returned as an existing model instance. Otherwise, they will be returned as a fresh (unsaved) instance of that model.

get_preferences_form(user, *args, **kwargs)[source]

Returns the preference form for a user. All other arguments are passed to the form initialization.

init_deposit(paper, user)[source]

Called when a user starts considering depositing a paper to a repository.

  • paper – The paper to be deposited.
  • user – The user submitting the deposit.

a boolean indicating if the repository can be used in this case.


Logs a line in the protocol log.

log_request(r, expected_status_code, error_msg)[source]

Logs an HTTP request and raises an error if the status code is unexpected.

preferences_form_class = None

The class of the form to edit the user preferences

preferences_model_name = None

The name of the model for the user preferences (set to None if no preferences can be set). The format should be (app_label, model_name) otherwise.


Returns an identifier for the protocol.


Given the DepositRecord created by a previous deposit, update its deposit status. This function will be called regularly, so that we can stay in sync with the deposit while it makes it way through the pipeline in the repository.

By default this does not do anything (i.e. leaves the DepositRecord unchanged).

Parameters:deposit_record – the DepositRecord to update
submit_deposit(pdf, form, dry_run=False)[source]

Submit a paper to the repository. This is expected to raise DepositError if something goes wrong.

  • pdf – Filename to the PDF file to submit
  • form – The form returned by get_form and completed by the user.
  • dry_run – if True, should

a DepositResult object.

submit_deposit_wrapper(*args, **kwargs)[source]

Wrapper of the submit_deposit method (that should not need to be reimplemented). It catches DepositErrors raised in the deposit process and adds the logs to its return value.