arxiv.users.domain module

Defines user concepts for use in arXiv-NG services.

class arxiv.users.domain.Authorizations[source]

Bases: tuple

Authorization information, e.g. associated with a Session.

classmethod before_init(data)[source]

Make sure that endorsements are Category instances.

Return type:None
classic

Capability code associated with a user’s session.

endorsements

Categories to which the user is permitted to submit.

scopes

Authorized scope`s. See also :mod:`arxiv.users.auth.scopes.

class arxiv.users.domain.Category[source]

Bases: tuple

Reprents a classification category.

archive

Archives group together related subjects in a domain.

compound

Compound category name.

Return type:str
display

Display name for this category.

Return type:str
classmethod from_compound(category)[source]

Create a Category from a compound classification slug.

E.g. “astro-ph.CO” -> Category(archive=”astro-ph”, subject=”CO”)

Parameters:category (str) – A dot-delimited compound category slug.
Returns:
Return type:Category
Return type:Category
subject

Leaf-level classification in the arXiv taxonomy.

class arxiv.users.domain.Client[source]

Bases: tuple

API client.

client_id

Unique identifier for a Client.

description

Brief description of the API client.

name

Human-friendly name of the API client.

owner_id

The arXiv user responsible for the client.

redirect_uri

The authorized redirect URI for the client.

url

Homepage or other resource describing the API client.

class arxiv.users.domain.Scope[source]

Bases: tuple

Represents an authorization policy.

action

An action within ``domain`.

class actions[source]

Bases: object

Known authorization actions.

CREATE = 'created'
DELETE = 'delete'
PROXY = 'proxy'
READ = 'read'
RELEASE = 'release'
UPDATE = 'update'
as_global()[source]

Create a copy of this scope with a global resource.

Return type:Scope
domain

The domain to which the scope applies.

This will generally refer to a specific service.

class domains[source]

Bases: object

Known authorization domains.

PROFILE = 'profile'

arXiv user profile.

PUBLIC = 'public'

The public arXiv site, including APIs.

SUBMISSION = 'submission'

Submission interfaces and actions.

UPLOAD = 'upload'

File uploads, including those for submissions.

for_resource(resource_id)[source]

Create a copy of this scope with a specific resource.

Return type:Scope
resource

The specific resource to which this policy applies.

class arxiv.users.domain.Session[source]

Bases: tuple

Represents an authenticated session in the arXiv system.

authorizations

Authorizations for the current session.

client

The client for which the session was created.

end_time

The ISO-8601 datetime when the session ended.

expired

Expired if the current time is later than end_time.

Return type:bool
expires

Number of seconds until the session expires.

If the session is already expired, returns 0.

Return type:Optional[int]
ip_address

The IP address of the client for which the session was created.

nonce

A pseudo-random nonce generated when the session was created.

remote_host

The hostname of the client for which the session was created.

session_id

Unique identifier for the session.

start_time

The ISO-8601 datetime when the session was created.

user

The user for which the session was created.

class arxiv.users.domain.User[source]

Bases: tuple

Represents an arXiv user and their authorizations.

email

The user’s primary e-mail address.

name

The user’s full name (if available).

profile

The user’s account profile (if available).

user_id

Unique identifier for the user. If None, the user does not exist.

username

Slug-like username.

verified

Whether or not the users’ e-mail address has been verified.

class arxiv.users.domain.UserFullName[source]

Bases: tuple

Represents a user’s full name.

forename

First name or given name.

suffix

Any title or qualifier used as a suffix/postfix.

surname

Last name or family name.

class arxiv.users.domain.UserProfile[source]

Bases: tuple

User profile data.

GRAD_STUDENT = ('4', 'Grad student')
OTHER = ('5', 'Other')
POST_DOC = ('3', 'Post doc')
PROFESSOR = ('2', 'Professor')
RANKS = [('1', 'Staff'), ('2', 'Professor'), ('3', 'Post doc'), ('4', 'Grad student'), ('5', 'Other')]
STAFF = ('1', 'Staff')
affiliation

Institutional affiliation.

country

Should be an ISO 3166-1 alpha-2 country code.

default_archive

The archive of the default category.

Return type:str
default_category

Default submission category.

Should be one of arxiv.taxonomy.CATEGORIES.

default_subject

The subject of the default category.

Return type:Optional[str]
groups_display

Display-ready representation of active groups for this profile.

Return type:str
homepage_url

User’s homepage or external profile URL.

rank

Academic rank. Must be one of UserProfile.RANKS.

rank_display

The display name of the user’s rank.

Return type:str
remember_me

Indicates whether the user prefers permanent session cookies.

submission_groups

Groups to which the user prefers to submit.

Items should be one of arxiv.taxonomy.GROUPS.

arxiv.users.domain.from_dict(cls, data)[source]

Generate a NamedTuple instance from a dict, with recursion.

This is the inverse of to_dict().

It’s easy to instantiate NamedTuples from dicts, but it’s not so easy if a NamedTuple field is typed with another NamedTuple. This function instantiates a NamedTuple class cls with the data in dict data, and also instantiates any referenced NamedTuple classes expected by cls’s fields with the appropriate data in data.

Parameters:
  • cls (type) – Any NamedTuple class.
  • data (dict) – Data with which to instantiate cls and its children.
Returns:

An instance of cls.

Return type:

NamedTuple

Return type:

Any

arxiv.users.domain.to_dict(obj)[source]

Generate a dict representation of a NamedTuple instance.

This just uses the built-in _asdict method on the intance, but also calls this on any child NamedTuple instances (recursively) so that the entire tree is cast to dict.

Parameters:obj (tuple) – A NamedTuple instance.
Returns:
Return type:dict
Return type:dict