arxiv.submission.services.classic package¶
Integration with the classic database to persist events and submission state.
As part of the classic renewal strategy, development of new submission interfaces must maintain data interoperability with classic components. This service module must therefore do three main things:
Store and provide access to event data generated during the submission process,
Keep the classic database tables up to date so that “downstream” components can continue to operate.
Patch NG submission data with state changes that occur in the classic system. Those changes will be made directly to submission tables and not involve event-generation. See
get_submission()
for details.
Since classic components work directly on submission tables, persisting events
and resulting submission state must occur in the same transaction. We must also
verify that we are not storing events that are stale with respect to the
current state of the submission. To achieve this, the caller should use the
util.transaction()
context manager, and (when committing new events)
call get_submission()
with for_update=True
. This will trigger a
shared lock on the submission row(s) involved until the transaction is
committed or rolled back.
ORM representations of the classic database tables involved in submission
are located in classic.models
. An additional model, DBEvent
,
is defined in classic.event
.
See also Integration with the legacy system.
-
arxiv.submission.services.classic.
create_all
()[source]¶ Create all tables in the database.
- Return type
None
-
arxiv.submission.services.classic.
drop_all
()[source]¶ Drop all tables in the database.
- Return type
None
-
arxiv.submission.services.classic.
get_events
(submission_id)[source]¶ Load events from the classic database.
- Parameters
submission_id (int) –
- Return type
- Returns
list – Items are
Event
instances loaded from the class DB.- Raises
classic.exceptions.NoSuchSubmission – Raised when there are no events for the provided submission ID.
-
arxiv.submission.services.classic.
get_licenses
()[source]¶ Get a list of
domain.License
instances available.
-
arxiv.submission.services.classic.
get_submission
(submission_id, for_update=False)[source]¶ Get the current state of a submission from the database.
In the medium term, services that use this package will need to play well with legacy services that integrate with the classic database. For example, the moderation system does not use the event model implemented here, and will therefore cause direct changes to the submission tables that must be reflected in our representation of the submission.
Until those legacy components are replaced, this function loads both the event stack and the current DB state of the submission, and uses the DB state to patch fields that may have changed outside the purview of the event model.
- Parameters
submission_id (int) –
- Return type
Tuple
[Submission
,List
[Event
]]- Returns
list – Items are
Event
instances.
-
arxiv.submission.services.classic.
get_submission_fast
(submission_id)[source]¶ Get the projection of the submission directly.
Instead of playing events forward, we grab the most recent snapshot of the submission in the database. Since classic represents the submission using several rows, we have to grab all of them and transform/patch as appropriate.
- Parameters
submission_id (int) –
- Return type
- Returns
- Raises
classic.exceptions.NoSuchSubmission – Raised when there are is no submission for the provided submission ID.
-
arxiv.submission.services.classic.
get_titles
(since)[source]¶ Get titles from submissions created on or after a particular date.
-
arxiv.submission.services.classic.
get_user_submissions_fast
(user_id)[source]¶ Get active NG submissions for a user.
This should not return submissions for which there are no events.
Uses the same approach as
get_submission_fast()
.- Parameters
submission_id (int) –
- Return type
- Returns
list – Items are the user’s
domain.submission.Submission
instances.
-
arxiv.submission.services.classic.
handle_operational_errors
(func)[source]¶ Catch SQLAlchemy OperationalErrors and raise
Unavailable
.
-
arxiv.submission.services.classic.
init_app
(app)[source]¶ Register the SQLAlchemy extension to an application.
- Return type
None
-
arxiv.submission.services.classic.
is_available
(**kwargs)[source]¶ Check our connection to the database.
- Return type
-
arxiv.submission.services.classic.
store_event
(event, before, after, *call)[source]¶ Store an event, and update submission state.
This is where we map the NG event domain onto the classic database. The main differences are that:
In the event domain, a submission is a single stream of events, but in the classic system we create new rows in the submission database for things like replacements, adding DOIs, and withdrawing papers.
In the event domain, the only concept of the announced paper is the paper ID. In the classic submission database, we also have to worry about the row in the Document database.
We assume that the submission states passed to this function have the correct paper ID and version number, if announced. The submission ID on the event and the before/after states refer to the original classic submission only.
- Parameters
event (
Event
) –before (
Submission
) – The state of the submission before the event occurred.after (
Submission
) – The state of the submission after the event occurred.call (list) – Items are callables that accept args
Event, Submission, Submission
. These are called within the transaction context; if an exception is raised, the transaction is rolled back.
- Return type
Tuple
[Event
,Submission
]
Subpackages¶
Submodules¶
- arxiv.submission.services.classic.bootstrap module
- arxiv.submission.services.classic.event module
- arxiv.submission.services.classic.exceptions module
- arxiv.submission.services.classic.interpolate module
- arxiv.submission.services.classic.load module
- arxiv.submission.services.classic.log module
- arxiv.submission.services.classic.models module
- arxiv.submission.services.classic.patch module
- arxiv.submission.services.classic.proposal module
- arxiv.submission.services.classic.util module