oarepo_config
oarepo_config
Helper functions for writing a clean, high-level invenio.cfg.
Instead of hand-assembling dozens of Flask/Invenio config constants,
invenio.cfg calls a small number of configure_*() functions from
this package. Each one computes a group of related settings and writes
them directly into invenio.cfg's own configuration, as if you had
set them by hand:
import oarepo_config as config
from invenio_i18n import (
lazy_gettext as _,
)
config.initialize_i18n()
config.configure_generic_parameters(
languages=(("cs", _("Czech")),),
)
config.configure_ui(
code="myrepo",
name=_("My repository"),
description=_(
"Description of my repository"
),
)
config.configure_communities()
config.configure_cron()
config.configure_stats()
# Feel free to add/override plain CONFIG_VARIABLE = value assignments
# below, or use config.configure_vocabulary(...), config.add_model(...),
# config.register_workflow(...), etc. for further options.
See the project's README for the full list of available functions, the order they should be called in, and the environment variables they read.
Modules:
| Name | Description |
|---|---|
ark |
Configuration for ARK persistent identifiers (oarepo-ark). |
base |
Base configuration utilities for oarepo-config. |
collections |
Configuration for collections. |
communities |
Configuration for communities. |
cron |
Configuration for periodic (scheduled) background tasks. |
datastreams |
Configuration for datastreams. |
detail_sidebar |
Configuration of the boxes in the record detail page sidebar. |
einfra |
Configuration for oarepo-oidc-einfra module. |
files |
Configuration for record files and upload quotas. |
generic_parameters |
Generic configuration parameters for oarepo-config. |
i18n |
Configuration for i18n. |
jobs |
Configuration for the Jobs feature. |
llm |
Configuration for oarepo-checks. |
models |
Configuration for models. |
oai |
Configuration for OAI-PMH. |
rdm_defaults |
InvenioRDM flavour defaults that only make sense for a deployed repository. |
requests |
Requests permission policy for oarepo-config. |
stats |
Configuration for invenio-stats module. |
ui |
Configuration for the repository UI. |
vocabulary |
Configuration for vocabulary. |
workflows |
Configuration for workflows. |
CSP
dataclass
Content Security Policy configuration.
Source code in oarepo_config/ui.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
default_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Fallback for any directive below that is left unset.
script_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for JavaScript.
script_src_elem: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <script> elements. Falls back to script_src.
script_src_attr: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for inline event handler attributes. Falls back to script_src.
style_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for CSS.
style_src_elem: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <style> elements. Falls back to style_src.
style_src_attr: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for inline style attributes. Falls back to style_src.
img_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for images.
font_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for fonts.
connect_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for fetch/XHR/WebSocket/EventSource calls (e.g. REST API endpoints).
object_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <object>, <embed> and <applet> plugins.
media_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for <audio>, <video> and <embed> media.
frame_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for nested browsing contexts (<iframe>).
frame_ancestors: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Sources allowed to embed this page; the modern replacement for X-Frame-Options.
child_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for nested browsing contexts and workers.
worker_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for Web Workers.
manifest_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for the application manifest.
prefetch_src: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources that may be prefetched.
form_action: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid targets for <form> submissions.
base_uri: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Valid sources for the document's <base> element.
report_to: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Report-To group name(s) to send CSP reports to; the modern replacement for report_uri.
report_uri: str | None = None
class-attribute
instance-attribute
URL to send CSP violation reports to.
report_only: bool = False
class-attribute
instance-attribute
Report violations without enforcing the policy. Requires report_uri.
apply_defaults(headers: dict[str, Any]) -> dict[str, Any]
Resolve this policy against the content_security_policy already in headers.
Directives set here are merged with the sources already configured for
them (or, lacking those, with the sources of the directive they'd fall
back to, e.g. default-src for connect_src), so that setting one
directive doesn't silently drop defaults the app still needs. Unset
directives keep the configured value as-is. Same for report_uri,
report_only.
The result replaces the CSP keys in headers rather than merging into
them: headers.update(csp.apply_defaults(headers)).
Raises:
| Type | Description |
|---|---|
ValueError
|
If report-only mode ends up enabled without any
|
Source code in oarepo_config/ui.py
CommunityWorkflow
dataclass
Bases: BaseWorkflowSettings
Workflow configuration for deposits inside communities.
Source code in oarepo_config/workflows/simplified/community.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
draft_creation_community_roles: list[str] = dataclasses.field(default_factory=lambda: ['submitter', 'curator', 'owner'])
class-attribute
instance-attribute
Restrict draft creation to community members with at least one of these roles.
If not specified (empty list), any member of the community can create a
draft. Used in addition to the site-wide
draft_creation_roles /
draft_creation_needs restrictions.
read_restricted_community_roles: list[str] = dataclasses.field(default_factory=lambda: ['curator', 'owner'])
class-attribute
instance-attribute
Community roles that may read restricted (published) records without requesting access.
If empty, only the record owner can read the content after publishing. By default allowing curators and community owners to access restricted records.
Note
Community roles are used instead of
RecordCommunitiesAction
so that each workflow can have independent read/draft/manage permissions.
read_draft_community_roles: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Community roles that may read draft records without requesting access.
If empty, only the record owner can read the content of a draft. Curators can always read draft records when the record is submitted for review.
Note
Community roles are used instead of
RecordCommunitiesAction
so that each workflow can have independent read/draft/manage permissions.
record_manage_community_roles: list[str] = dataclasses.field(default_factory=lambda: ['curator', 'owner'])
class-attribute
instance-attribute
Community roles that may manage (edit, delete, publish) records.
If empty, only the record owner can manage the record. By default allowing curators and community owners to manage all records.
Note
Community roles are used instead of
RecordCommunitiesAction
so that each workflow can have independent read/draft/manage permissions.
community_curator_roles: list[str] = dataclasses.field(default_factory=lambda: ['curator'])
class-attribute
instance-attribute
Community roles that allow users to review and curate records.
IndividualWorkflow
dataclass
Bases: BaseWorkflowSettings
Workflow configuration for deposits outside of communities.
Source code in oarepo_config/workflows/simplified/individual.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
code: str = 'individual'
class-attribute
instance-attribute
Unique code identifier for this workflow.
label: LazyString = _('Individual Submission Workflow')
class-attribute
instance-attribute
Human-readable label for this workflow.
authenticated_draft_creation: bool = True
class-attribute
instance-attribute
Allow authenticated users to create drafts in this workflow.
Overrides the base-class default of False; any authenticated user can
create a draft unless more-specific role or need restrictions are configured
via draft_creation_roles or
draft_creation_needs.
publish_without_review: bool = False
class-attribute
instance-attribute
Allow draft owners to publish without submitting a review request.
When enabled, draft owners can publish directly, subject to
publish_without_review_states.
publish_without_review_roles: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Roles that allow a draft owner to publish without a review request.
Users must still be owners of the draft record. If the list is non-empty,
publish_without_review is ignored.
publish_without_review_needs: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Permission needs that allow a draft owner to publish without a review request.
Users must still be owners of the draft record. If the list is non-empty,
publish_without_review is ignored.
publish_without_review_states: list[str] = dataclasses.field(default_factory=lambda: ['draft'])
class-attribute
instance-attribute
Record workflow states in which publication without review is allowed.
review_required: bool = False
class-attribute
instance-attribute
Require a review request before publication.
If publish_without_review is False and review_required
is False, records can only be published through a community workflow.
reviewer_roles: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Roles that allow users to review and curate records.
Users with these roles are also granted read access to draft records.
reviewer_needs: list[str] = dataclasses.field(default_factory=list)
class-attribute
instance-attribute
Permission needs that allow users to review and curate records.
Users with these needs are also granted read access to draft records.
self_review_enabled: bool = False
class-attribute
instance-attribute
Allow the record owner to approve their own review request.
Normally, submitting a record for review prevents the owner from approving it
themselves. When set to True, the review request is still created on
submission, but the owner is permitted to accept it.
This is primarily useful when invenio-checks is active: checks are tied
to an open request, so the request must exist even when no external reviewer
is needed. With this option the owner can see and act on the check results
without waiting for a curator.
Has no effect when publish_without_review is True, because in
that case user can bypass the review request and publish the record directly.
record_owners_with_correct_roles(record_owner_generator: RecordOwners) -> list[Generator]
Return the record owner generator with the correct roles/needs.
Source code in oarepo_config/workflows/simplified/individual.py
configure_ark(*, default_shoulder: str, shoulders: dict[str, str] | None = None, naan: str = '99999', handlers: dict[str, type | str] | None = None, default_handler: type | str | None = None, public_resolver: str | None = None, support: dict[str, str] | None = None, show_in_sidebar: bool = True) -> None
Give every record published as public an ARK (Archival Resource Key).
Requires the optional oarepo-ark package. If this function is not
called, the package is installed but inert: no ARKs are minted and the
/ark:... resolver answers 404.
Must be called after configure_ui, because it
appends the ARK box to the detail page sidebar that configure_ui sets; calling it
earlier raises an error (unless show_in_sidebar is False).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_shoulder
|
str
|
The shoulder used for all models, e.g. |
required |
shoulders
|
dict[str, str] | None
|
Per-model shoulder overrides, keyed by the model's
service id (the model name, or its |
None
|
naan
|
str
|
Your NAAN from https://arks.org/. Defaults to the test NAAN
|
'99999'
|
handlers
|
dict[str, type | str] | None
|
Per-model handler class (or its import string), keyed by the model's service id. |
None
|
default_handler
|
type | str | None
|
Handler class (or its import string) of all other
models. Defaults to oarepo-ark's |
None
|
public_resolver
|
str | None
|
Resolver used in citable ARK URLs. Defaults to
|
None
|
support
|
dict[str, str] | None
|
The |
None
|
show_in_sidebar
|
bool
|
Add the |
True
|
Invenio configuration variables set:
ARK_NAAN,ARK_DEFAULT_SHOULDER,ARK_SHOULDERS,ARK_HANDLERS- from the arguments above.ARK_DEFAULT_HANDLER,ARK_PUBLIC_RESOLVER,ARK_SUPPORT- only if the corresponding argument is given.APP_RDM_DETAIL_SIDE_BAR_TEMPLATES- thearkbox is added ifshow_in_sidebarisTrue.
Example
Source code in oarepo_config/ark.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
configure_datastreams(readers: dict[str, Any] | None = None, writers: dict[str, Any] | None = None, transformers: dict[str, Any] | None = None) -> None
Register custom sources for importing vocabularies (fixtures) into the repository.
Vocabularies (controlled lists such as languages, resource types or licenses) can be loaded from files or external services using "datastreams" - a reader that fetches/reads the raw data, an optional transformer that converts it, and a writer that stores it. Invenio already ships with a set of built-in readers/writers/ transformers; use this function only if you need to add your own (for example, a reader that pulls a vocabulary from a custom REST API).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
readers
|
dict[str, Any] | None
|
Extra readers to make available, as a mapping of a
short name to either an import path string
( |
None
|
writers
|
dict[str, Any] | None
|
Extra writers to make available, in the same format as
|
None
|
transformers
|
dict[str, Any] | None
|
Extra transformers to make available, in the same
format as |
None
|
Any readers/writers/transformers already registered (for example by
configure_generic_parameters) are kept; the ones passed here
are added on top.
Invenio configuration variables set:
VOCABULARIES_DATASTREAM_READERS- only ifreadersis given; merged with any existing value.VOCABULARIES_DATASTREAM_WRITERS- only ifwritersis given; merged with any existing value.VOCABULARIES_DATASTREAM_TRANSFORMERS- only iftransformersis given; merged with any existing value.
Example
Source code in oarepo_config/datastreams.py
configure_detail_sidebar(*, templates: dict[str, str] | None = None, order: list[str] | None = None, move: list[str] | None = None, remove: list[str] | None = None, model: str | None = None) -> None
Change the boxes shown in the sidebar of the record detail page.
The boxes are referred to by symbolic names (see
DETAIL_SIDEBAR_TEMPLATES):
manage_menu, versions, external_resources, communities,
keywords_subjects, details, locations, licenses,
citations, export, technical_metadata, metrics and ark
(added by configure_ark). A box
registered via templates is referred to by its new name.
The changes are applied to the current sidebar, in this order:
templates, order, move, remove. Must be called after
configure_ui and any other configure_*
function that adds a box (e.g. configure_ark).
Can be called multiple times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
templates
|
dict[str, str] | None
|
Box name -> template. An existing box gets the new template in place; a new box is appended at the end. |
None
|
order
|
list[str] | None
|
The new order of the boxes. |
None
|
move
|
list[str] | None
|
Moves applied one after another, each one of
|
None
|
remove
|
list[str] | None
|
Boxes to remove. |
None
|
model
|
str | None
|
Change only the sidebar of this model (the model name). Its sidebar starts as a copy of the global one. |
None
|
Invenio configuration variables set:
APP_RDM_DETAIL_SIDE_BAR_TEMPLATES- withoutmodel.OAREPO_UI_SIDEBAR_TEMPLATES[model]- withmodel._OAREPO_CONFIG_DETAIL_SIDEBAR_TEMPLATES- internal: the boxes registered viatemplates, per sidebar (model name,Nonefor the global one), so that later calls know their names.
Example
Source code in oarepo_config/detail_sidebar.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
configure_einfra_oidc(entitlements_parser: EntitlementsParser | None = None) -> None
Set up "Log in with e-INFRA" (CESNET/Perun) for the repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entitlements_parser
|
EntitlementsParser | None
|
A callable that parses the user's entitlements. |
None
|
This enables single sign-on through the CESNET e-INFRA identity provider, so users can log in with their e-INFRA/Perun account instead of (or in addition to) a local username and password. It also makes user profile information (name, e-mail, ...) read-only locally, since it is then managed by e-INFRA instead.
Requires the optional oarepo-oidc-einfra package to be
installed - if it is missing, this function prints a message and
stops the application from starting.
Whether e-INFRA login is actually turned on is controlled by the
INVENIO_REMOTE_AUTH_ENABLED setting (true/yes/1 to
enable it, anything else - including leaving it unset - disables
it). When enabled, the client credentials
INVENIO_EINFRA_CONSUMER_KEY and INVENIO_EINFRA_CONSUMER_SECRET
must also be provided (see the deployment's variables/.env
configuration).
Invenio configuration variables set:
OAUTHCLIENT_REMOTE_APPS- always updated (merged with any existing value); gets an"e-infra"entry only when e-INFRA login is enabled.EINFRA- only when e-INFRA login is enabled; the e-INFRA client credentials and endpoint configuration.USERPROFILES_READ_ONLY- only when e-INFRA login is enabled; forced toTrue.
Make sure to set INVENIO_REMOTE_AUTH_ENABLED=true and provide
INVENIO_EINFRA_CONSUMER_KEY and INVENIO_EINFRA_CONSUMER_SECRET
in your deployment's variables or environment.
Source code in oarepo_config/einfra.py
configure_files(max_file_size: int = 1 * 10 ** 9, max_files_count: int = 100, max_total_size: int = 5 * 10 ** 9, allow_metadata_only_records: bool = True, allow_empty_files: bool | None = None, file_modification_grace_period: timedelta = timedelta(days=45), allow_immediate_file_modification: bool = True, allow_immediate_quota_increase: bool = True, max_additional_quota_size: int = 0, allow_archive_download: bool = True, max_archive_download_size: int | None = None) -> None
Set up file upload quotas and file-related toggles.
Controls how many files users may attach to a record deposition, how large each individual file may be, the total storage budget for the deposition, whether a deposition can be published without any files at all, and whether uploaded files may have zero bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_file_size
|
int
|
Maximum size of a single uploaded file in bytes.
Defaults to 1 GB ( |
1 * 10 ** 9
|
max_files_count
|
int
|
Maximum number of files allowed per record
deposition. Defaults to |
100
|
max_total_size
|
int
|
Maximum combined size of all files in a single
record deposition, in bytes. Defaults to 5 GB
( |
5 * 10 ** 9
|
allow_metadata_only_records
|
bool
|
When |
True
|
allow_empty_files
|
bool | None
|
When |
None
|
file_modification_grace_period
|
timedelta
|
Grace period after a record is
published during which its files can still be modified without
creating a new version. Checked at publish time. Defaults to
45 days ( |
timedelta(days=45)
|
allow_immediate_file_modification
|
bool
|
When |
True
|
allow_immediate_quota_increase
|
bool
|
When |
True
|
max_additional_quota_size
|
int
|
Additional quota users/admins may grant on top of the default record quota. Defaults to 0. |
0
|
allow_archive_download
|
bool
|
Whether all files of a record can be
downloaded at once as a single ZIP archive ("Download all").
The archive is assembled on the fly by a web worker, which
stays busy for the whole download. Defaults to |
True
|
max_archive_download_size
|
int | None
|
Largest total size of a record's files,
in bytes, for which the "Download all" archive is still
offered; larger records only offer per-file downloads. |
None
|
Invenio configuration variables set:
RDM_FILES_DEFAULT_MAX_FILE_SIZE- backend limit on the size of a single file.RDM_FILES_DEFAULT_QUOTA_SIZE- backend limit on the total size of all files in a record deposition.RDM_RECORDS_MAX_FILES_COUNT- backend limit on the number of files per record.RDM_ALLOW_METADATA_ONLY_RECORDS- whether metadata-only records are allowed.RECORDS_RESOURCES_ALLOW_EMPTY_FILES- whether zero-byte files may be uploaded.RDM_FILE_MODIFICATION_PERIOD- time window after record creation during which modified files may be published.RDM_IMMEDIATE_FILE_MODIFICATION_ENABLED- whether published files may be edited immediately; set toallow_immediate_file_modification.RDM_IMMEDIATE_FILE_MODIFICATION_POLICIES- ordered list of policies deciding who may edit published files immediately (only set whenallow_immediate_file_modificationisTrue).RDM_IMMEDIATE_QUOTA_INCREASE_ENABLED- whether users may immediately raise a draft's quota; set toallow_immediate_quota_increase.RDM_IMMEDIATE_QUOTA_INCREASE_POLICIES- ordered list of policies deciding who may raise a draft's quota (only set whenallow_immediate_quota_increaseisTrue).APP_RDM_DEPOSIT_FORM_QUOTA- deposit-form UI quota object withmaxFilesandmaxStorage.FILES_REST_DEFAULT_MAX_FILE_SIZEandFILES_REST_DEFAULT_QUOTA_SIZE- fallback variables used by the lower-level file storage layer.RDM_FILES_DEFAULT_MAX_ADDITIONAL_QUOTA_SIZE- themax_additional_quota_sizeabove.RDM_ARCHIVE_DOWNLOAD_ENABLED- whether the "Download all" archive is available.RECORDS_RESOURCES_ARCHIVE_DOWNLOAD_MAX_SIZE- total size limit for the "Download all" archive.
Example
# Use the default file quotas and toggles. All parameters below
# match the helper's built-in defaults and are shown explicitly
# for reference; they can be omitted when calling the helper.
config.configure_files(
max_file_size=1 * 10**9,
max_files_count=100,
max_total_size=5 * 10**9,
allow_metadata_only_records=True,
)
Source code in oarepo_config/files.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
configure_jobs(permission_policy: str | type | None = None, logging_level: str | None = None) -> None
Set up the "Jobs" feature (manually or automatically run administrative tasks).
Invenio-jobs lets administrators run and monitor maintenance tasks (such as re-indexing or fixing up data) from the admin panel, and view their logs. This decides who is allowed to view those job logs and how detailed the logs are.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permission_policy
|
str | type | None
|
Who is allowed to view job logs. By default, only administrators can. Pass your own permission policy class (or its import path as a string) to change this. |
None
|
logging_level
|
str | None
|
How detailed the job logs should be, e.g.
|
None
|
Invenio configuration variables set:
APP_LOGS_PERMISSION_POLICY- thepermission_policyabove.JOBS_LOGGING_LEVEL- thelogging_levelabove.
Example
Source code in oarepo_config/jobs.py
initialize_glitchtip(dsn: str | None = None, deployment_version: str | None = None) -> None
Set up automatic error reporting to Glitchtip/Sentry.
Requires the optional oarepo-glitchtip package; without it,
calling this raises an ImportError explaining that the
package needs to be installed first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dsn
|
str | None
|
The Glitchtip/Sentry project URL (DSN) errors should be sent to. |
None
|
deployment_version
|
str | None
|
A label identifying this deployment (e.g. a git commit or release tag), included with reported errors so they can be traced back to a specific version. |
None
|
Invenio configuration variables set: implemented entirely in
the separate oarepo-glitchtip package, so the exact set of
variables it writes is documented there, not here.
Source code in oarepo_config/__init__.py
load_configuration_variables() -> DictWithGetAttr
cached
Read the deployment's configuration values (INVENIO_... variables).
Collects configuration values set by the deployment, from multiple places, each one able to override the previous (lowest to highest priority):
- a
variablesfile next toinvenio.cfg(the instance directory); - a
variablesfile in the current working directory; - a
.envfile in the current working directory; - any
.json/.yaml/.ymlfiles under the directory named by theINVENIO_CONFIG_PATHenvironment variable, if set; - the actual process environment variables (always wins).
Values such as "True"/"False" or JSON snippets are converted
to real Python types (booleans, numbers, lists, dicts) where
possible. The result can be accessed both as a dictionary and via
attribute access (e.g. env.INVENIO_SECRET_KEY); accessing a
variable that was never set raises AttributeError.
Source code in oarepo_config/base.py
override_configuration(env: dict[str, Any] | None = None) -> None
Apply ad-hoc configuration overrides from the environment, without writing Python code.
Lets a deployment set (or override) any Invenio configuration value
directly from the variables/.env files or the process
environment, by prefixing its name with INVENIO_. For example,
setting INVENIO_RDM_ARCHIVE_DOWNLOAD_ENABLED=false in the
deployment's configuration will set the RDM_ARCHIVE_DOWNLOAD_ENABLED
setting to False, without needing to change invenio.cfg.
This is not applied automatically - call it explicitly from
invenio.cfg, typically as the very last step, so that these
overrides win over anything set by the configure_*() functions
above it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
dict[str, Any] | None
|
Normally left unset, in which case the values loaded from
|
None
|
Source code in oarepo_config/base.py
configure_collections(communities_collections_enabled: bool = True, max_depth: int = 2) -> None
Configure collections feature.
Collections and are curated, browsable subsets of a community's records. They are saved searches. Each collection stores a search query, and its records are whatever that query matches. A record is never added to a collection by hand.
Source code in oarepo_config/collections.py
configure_communities(communities_roles: list | None = None) -> None
Set up the configuration for communities.
Communities let you organize records into collections with their own managers and settings. This function configures who can do what in each community (the roles), how records are submitted to communities, and other community-related settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
communities_roles
|
list | None
|
Custom role definitions for communities. If not
provided, defaults to owner/curator/member roles. If omitted, three
default roles are used: "owner" (can manage the community
and its members), "curator" (can review/curate submitted
records) and "member" (can only view). Pass your own list to
replace the defaults, e.g. to add a "submitter" role. Each
role dictionary understands the keys |
None
|
Invenio configuration variables set:
COMMUNITIES_REGISTER_UI_BLUEPRINT- alwaysTrue; enables the communities UI.COMMUNITIES_PERMISSION_POLICY- the permission policy class for communities.COMMUNITIES_ROLES- the list of available roles in communities.
Example
config.configure_communities()
# or with custom settings:
config.configure_communities(
communities_roles=[
dict(
name="owner",
title=_("Community owner"),
is_owner=True,
can_manage=True,
can_manage_roles=[
"owner",
"curator",
"member",
"submitter",
],
),
dict(
name="curator",
title=_("Curator"),
can_manage=True,
can_manage_roles=[
"member",
"submitter",
],
),
dict(
name="submitter",
title=_("Submitter"),
can_manage=False,
),
dict(
name="member",
title=_("Member"),
),
]
)
Source code in oarepo_config/communities.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
configure_cron(file_integrity_check_days: int | None = None, **extra_cron_items: Any) -> None
Set up the periodic (scheduled) background tasks the repository needs.
The repository relies on a number of jobs that must run automatically in the background on a regular basis - for example, cleaning up old sessions, aggregating usage statistics, or clearing caches. This function sets up a sensible set of such jobs out of the box:
- keeping the search index queues healthy (every 10 seconds)
- cleaning up expired user sessions and old IP address logs
- processing and aggregating usage statistics (hourly)
- clearing the communities cache (daily)
- removing expired file-access-request tokens (daily)
- lifting expired embargoes (daily)
- expiring requests past their expiration date, e.g. community invitations (daily)
- purging drafts that were discarded more than an hour ago (hourly)
- deleting job logs older than
JOBS_LOGGING_RETENTION_DAYS(daily) - refreshing the sitemap (daily)
- updating the statistics of user e-mail domains (every 4 hours)
- recounting community collections (hourly) - only if
COMMUNITIES_COLLECTIONS_ENABLEDwas set toTrueearlier ininvenio.cfg
Compared to upstream InvenioRDM, reindex-stats is left out on
purpose: OARepo models do not index usage statistics into the record
documents, so there is nothing to refresh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_integrity_check_days
|
int | None
|
Turns on periodic fixity checking: every
stored file gets its checksum re-computed once per this many
days (spread evenly over hourly batches), and a daily e-mail
reports the files that are missing or corrupted to
|
None
|
**extra_cron_items
|
Any
|
{}
|
Invenio configuration variables set:
CELERY_BEAT_SCHEDULE- merged with any schedule already defined earlier ininvenio.cfg; entries from**extra_cron_itemswin over the built-in defaults listed above when their names collide.
Source code in oarepo_config/cron.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
configure_generic_parameters(languages: tuple[tuple[str, str], ...] = (('en', 'English'),), use_path_pid_ids: bool = False) -> None
Set up the core, infrastructure-level configuration of the repository.
This is the main "plumbing" function that should normally be called
first, before any of the other configure_* functions. It reads
most of its values from the deployment's environment configuration
(the variables/.env files or process environment variables,
all prefixed with INVENIO_) and uses them to configure:
- the site's public URLs, and allowed security headers
- whether local login/registration/password-reset is available
- the database, search engine (OpenSearch), file storage (S3), cache and message queue (Redis/RabbitMQ) connections
- translation/locale and file-upload defaults
-
default identifier schemes recognised for names, funders and affiliations (e.g. ORCID, ROR, VEDIDK, Scopus author ID)
-
the InvenioRDM security defaults that upstream ships in
invenio_app_rdm.configand that only make sense for a deployed repository (CSRF protection, shared rate limiting, database pool options, permission cache) - see "InvenioRDM flavour defaults" below
Because most values come from the environment, this function will
fail to start the application if a required INVENIO_... variable
is missing from the deployment's configuration - see the project's
README for the full list of variables it expects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
languages
|
tuple[tuple[str, str], ...]
|
Extra UI languages to offer, as a tuple of
|
(('en', 'English'),)
|
use_path_pid_ids
|
bool
|
Set this to |
False
|
Invenio configuration variables set, grouped by area:
Public URLs & security headers
* TRUSTED_HOSTS
* SITE_UI_URL, SITE_API_URL
* APP_DEFAULT_SECURE_HEADERS
Local login & accounts
* ACCOUNTS_LOCAL_LOGIN_ENABLED, SECURITY_REGISTERABLE,
SECURITY_RECOVERABLE, SECURITY_CHANGEABLE,
SECURITY_CONFIRMABLE,
SECURITY_LOGIN_WITHOUT_CONFIRMATION
* SESSION_COOKIE_SECURE
* RATELIMIT_GUEST_USER, RATELIMIT_AUTHENTICATED_USER
* OAUTHCLIENT_REMOTE_APPS - starts out empty here; extended
by configure_einfra_oidc if used.
* ACCOUNTS_LOGIN_VIEW_FUNCTION,
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN
Database
* SQLALCHEMY_DATABASE_URI
Translation/locale
* BABEL_DEFAULT_LOCALE, BABEL_DEFAULT_TIMEZONE,
I18N_LANGUAGES
Files & storage
* SEND_FILE_MAX_AGE_DEFAULT, FILES_REST_STORAGE_FACTORY
* S3_ENDPOINT_URL, S3_ACCESS_KEY_ID,
S3_SECRET_ACCESS_KEY
* FILES_REST_STORAGE_CLASS_LIST,
FILES_REST_DEFAULT_STORAGE_CLASS,
FILES_REST_DEFAULT_QUOTA_SIZE
* APP_RDM_DEPOSIT_FORM_QUOTA
User profiles
* USERPROFILES_READ_ONLY
OAI-PMH
* OAISERVER_ID_PREFIX
Search (OpenSearch)
* SEARCH_INDEX_PREFIX, SEARCH_HOSTS,
SEARCH_CLIENT_CONFIG - set INVENIO_OPENSEARCH_TIMEOUT
(seconds) to raise the search request timeout.
* VOCABULARIES_SERVICE_CONFIG,
VOCABULARIES_RESOURCE_CONFIG - only if the optional
oarepo_vocabularies package is installed.
Caches (Redis)
* INVENIO_CACHE_TYPE, CACHE_REDIS_URL,
ACCOUNTS_SESSION_REDIS_URL,
COMMUNITIES_IDENTITIES_CACHE_REDIS_URL
Background jobs (Celery/RabbitMQ)
* CELERY_BROKER_URL, BROKER_URL,
CELERY_RESULT_BACKEND
JSON schemas
* RECORDS_REFRESOLVER_CLS, RECORDS_REFRESOLVER_STORE,
JSONSCHEMAS_HOST
Secrets
* SECRET_KEY
Records/REST compatibility
* DASHBOARD_RECORD_CREATE_URL, RECORD_ROUTES,
RECORDS_REST_ENDPOINTS
DataCite/DOIs
* DATACITE_TEST_MODE
Mail
* MAIL_DEFAULT_SENDER
* MAIL_SUPPRESS_SEND - only if INVENIO_MAIL_SUPPRESS_SEND
is set in the environment.
Identifier/name/funder/affiliation vocabularies
* VOCABULARIES_NAMES_SCHEMES, VOCABULARIES_FUNDER_SCHEMES,
VOCABULARIES_AFFILIATION_SCHEMES - merged with any
existing value.
* APP_RDM_IDENTIFIER_SCHEMES_UI
* VOCABULARIES_DATASTREAM_READERS,
VOCABULARIES_DATASTREAM_WRITERS,
VOCABULARIES_DATASTREAM_TRANSFORMERS - seeded from
invenio-app-rdm's defaults, merged with any existing
value; see configure_datastreams to add your own.
Miscellaneous
* ROR_CLIENT_ID, SESSION_COOKIE_DOMAIN,
COLLECT_STORAGE
InvenioRDM flavour defaults
Upstream InvenioRDM applies these through
invenio_app_rdm.config, which OARepo does not load. The inert
ones are defaults of every OARepo application (see
oarepo.initial_rdm_config and oarepo_rdm.initial_config);
the ones below switch on enforcement or depend on the
deployment, so they are applied here. Each of them can be
overridden by a plain assignment later in invenio.cfg.
* `REST_CSRF_ENABLED` - CSRF protection of the REST API for
browser-session requests (API-token requests are exempt).
* `ACCESS_CACHE` - caches resolved action permissions.
* `RATELIMIT_STORAGE_URI` - rate limiting counters shared by
all web processes in Redis instead of per-process memory.
Taken from `INVENIO_RATELIMIT_STORAGE_URI`, or built from the
Redis connection and `INVENIO_REDIS_RATELIMIT_DB` (default
`4`).
* `ACCOUNTS_LOGIN_RATELIMIT`,
`ACCOUNTS_FORGOT_PASSWORD_EMAIL_RATELIMIT`,
`ACCOUNTS_SEND_CONFIRMATION_RATELIMIT`
* `SQLALCHEMY_ENGINE_OPTIONS` - connection pool recycling and
timeout, UTC session time zone, host name as the connection's
`application_name`. `INVENIO_PGBOUNCER_ENABLED=True` disables
pooling in the application; `INVENIO_SQLALCHEMY_ENGINE_OPTIONS`
(a JSON object) is merged over the result.
* `APP_RDM_ADMIN_EMAIL_RECIPIENT` - recipient of the file
integrity report, from
`INVENIO_APP_RDM_ADMIN_EMAIL_RECIPIENT`.
In addition, if use_path_pid_ids is True, this patches the
url_prefix of RDMParentRecordLinksResourceConfig,
RDMParentGrantsResourceConfig, RDMGrantUserAccessResourceConfig
and RDMGrantGroupAccessResourceConfig directly - this is a class
attribute change, not a new invenio.cfg variable.
Example
Source code in oarepo_config/generic_parameters.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
initialize_i18n() -> None
Enable translated validation error messages.
Makes sure that when a user submits invalid data (for example, a
required field is missing), the error message shown to them is
translated into their chosen language instead of always being shown
in English. Takes no parameters; call it once, near the top of
invenio.cfg.
Invenio configuration variables set: none - this only patches Marshmallow's error-message machinery in memory.
Source code in oarepo_config/i18n.py
configure_llm(api_token: str | None = None, *, enabled: bool = True, client_name: str = OAREPO_CHECKS_DEFAULT_CHAT_EINFRA_CLIENT, api_url: str = 'https://llm.ai.e-infra.cz/v1/chat/completions', model: str = 'nrp', fallback_community: str | None = None, as_default: bool = True) -> None
Set up the LLM client(s) used by oarepo-checks' AI-assisted record validation.
oarepo-checks can validate a record's metadata by sending it to a
Large Language Model and checking the response (its "llm" check,
shown to users as "AI validation") before a record may be published.
This registers one such LLM client (built-in support is for
chat.ai.e-infra.cz) that the check can use.
Call it once per LLM client/token you want available - each call reads
back and extends whatever a previous call already registered (via
get_constant_from_caller), it does not replace it. This also
means, when calling it more than once, that whichever call has
as_default=True last wins as the default client.
Requires the optional oarepo-checks package to be installed;
without it, calling this raises an ImportError explaining that the
package needs to be installed first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_token
|
str | None
|
Bearer token for the |
None
|
enabled
|
bool
|
Set to |
True
|
client_name
|
str
|
The key this client is registered under in
|
OAREPO_CHECKS_DEFAULT_CHAT_EINFRA_CLIENT
|
api_url
|
str
|
The |
'https://llm.ai.e-infra.cz/v1/chat/completions'
|
model
|
str
|
The model name the |
'nrp'
|
fallback_community
|
str | None
|
Slug of the community used for checks that
aren't tied to a specific community. If given, overrides
whatever a previous call already set; if not given, an
already-set value is kept, defaulting to
|
None
|
as_default
|
bool
|
Mark |
True
|
Invenio configuration variables set:
CHECKS_ENABLED- theenabledargument above.OAREPO_CHECKS_LLM_CLIENTS- only ifenabled; extended (not replaced) with aChatEInfraCliententry underclient_name, only ifapi_tokenwas given.OAREPO_CHECKS_DEFAULT_LLM_CLIENT- only ifenabledandas_default; set toclient_name.CHECKS_GENERIC_COMMUNITY- only ifenabled;fallback_communityif given, else an already-set value, else"llm-settings-community".
Example
Source code in oarepo_config/llm.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
add_model(model_package_name: str) -> None
Include a data model in the repository's global (cross-model) search.
Repositories can host several different kinds of records (models),
e.g. "datasets" and "publications". Call this once per model package
to make its records show up in searches that span all models at
once (as opposed to searching within just one model). This does not
register the model itself (its API endpoints, forms, etc.) - that is
normally done separately, by calling that model package's own
register() function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_package_name
|
str
|
The Python import path of the generated
model package to add, e.g. |
required |
Invenio configuration variables set:
GLOBAL_SEARCH_MODELS- the model'sMODEL_DEFINITIONis appended to this list; any models already registered (by earlier calls, or by other packages) are kept.
Source code in oarepo_config/models.py
configure_oai(repository_name: str | None = None, admin_emails: list[str] | tuple[str, ...] | str | None = None, page_size: int = 50, resumption_token_expire_time: int = 120) -> None
Set up OAI-PMH, the protocol other systems use to harvest records from this repository.
OAI-PMH is a standard way for external services (e.g. national
aggregators, other repositories) to regularly fetch a list of
published records. This announces the repository's name and contact
over that protocol, using the values already set via
configure_ui, and tunes the paging of
list responses.
Unless repository_name is given, this must be called after
configure_ui, since it needs the
repository name that function sets up; calling it earlier raises an
error explaining this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repository_name
|
str | None
|
Name announced in the |
None
|
admin_emails
|
list[str] | tuple[str, ...] | str | None
|
E-mail address(es) published as the repository's
administrative contact in the |
None
|
page_size
|
int
|
Number of records returned per |
50
|
resumption_token_expire_time
|
int
|
How long, in seconds, a harvester may wait before asking for the next page. Defaults to 120 (invenio-oaiserver's own default is 60). |
120
|
Invenio configuration variables set:
OAISERVER_REPOSITORY_NAME- therepository_nameabove, or a copy ofREPOSITORY_NAME(set byconfigure_ui).OAISERVER_ADMIN_EMAILS- theadmin_emailsabove, if known.OAISERVER_PAGE_SIZE- thepage_sizeabove.OAISERVER_RESUMPTION_TOKEN_EXPIRE_TIME- theresumption_token_expire_timeabove.
Example
Source code in oarepo_config/oai.py
configure_stats(enable: bool = True, count_preview_downloads: bool = True) -> None
Set up usage statistics (record views, downloads, etc.).
Enables the collection and aggregation of usage events, such as how many times a record was viewed or a file was downloaded, so this data can later be shown to users and curators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
Set to |
True
|
count_preview_downloads
|
bool
|
Whether a file fetched by the in-page
file previewer counts as a download. |
True
|
Invenio configuration variables set:
STATS_REGISTER_RECEIVERS- theenableargument above.RDM_STATS_EXCLUDE_PREVIEW_FILE_DOWNLOAD_EVENTS- the inverse ofcount_preview_downloads.STATS_EVENTS,STATS_AGGREGATIONS,STATS_QUERIES,STATS_PERMISSION_FACTORY- always set toinvenio-app-rdm's defaults, regardless ofenable.
Source code in oarepo_config/stats.py
configure_ui(code: str = 'myrepo', name: str | Any = 'My Repository', subtitle: str = '', description: str = '', support_contact: str = '', keywords: str = '', use_default_frontpage: bool = False, show_frontpage_intro: bool = True, analytics: str | bool = False, languages: tuple[tuple[str, str], ...] = (('en', 'English'),), csp: CSP | None = None) -> None
Set up the repository's branding, name and general look-and-feel.
Configures what visitors see: the repository's name and description shown in the browser tab/search results/front page, the theme, the page layout templates, and (optionally) analytics tracking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
A short, technical, all-lowercase identifier for this
repository (e.g. |
'myrepo'
|
name
|
str | Any
|
The repository's display name, shown in the browser title
and on the front page, e.g. |
'My Repository'
|
subtitle
|
str
|
A short subtitle/tagline shown next to the name. |
''
|
description
|
str
|
A longer description of the repository, used for SEO and on the front page. |
''
|
support_contact
|
str
|
Contact information (e.g. an e-mail address) shown to users who need help. |
''
|
keywords
|
str
|
Keywords describing the repository's content, used for SEO. |
''
|
use_default_frontpage
|
bool
|
Whether to use Invenio's generic front
page. Most repositories provide a custom front page, so this
defaults to |
False
|
show_frontpage_intro
|
bool
|
Whether to show the introductory text section on the front page. |
True
|
analytics
|
str | bool
|
Set to |
False
|
languages
|
tuple[tuple[str, str], ...]
|
Extra UI languages to offer, as a tuple of
|
(('en', 'English'),)
|
csp
|
CSP | None
|
Content Security Policy configuration. Only the sources passed
here are recorded; the ones the deployment already allows (set up
by |
None
|
Should be called after configure_generic_parameters (it
builds on settings that function prepares) and before
configure_oai (which needs the repository name set here).
Example
Invenio configuration variables set, grouped by area:
Versioning
* DEPLOYMENT_VERSION
Theme & security
* APP_THEME
* APP_DEFAULT_SECURE_HEADERS - extends the value prepared by
configure_generic_parameters.
Page layout templates
* INSTANCE_THEME_FILE
* BASE_TEMPLATE, ADMINISTRATION_THEME_BASE_TEMPLATE,
COVER_TEMPLATE
* THEME_CSS_TEMPLATE, THEME_JAVASCRIPT_TEMPLATE
* HEADER_TEMPLATE, THEME_HEADER_TEMPLATE,
THEME_HEADER_LOGIN_TEMPLATE, THEME_FOOTER_TEMPLATE
* THEME_TRACKINGCODE_TEMPLATE, THEME_FRONTPAGE_TEMPLATE
* SETTINGS_TEMPLATE, SEARCH_UI_SEARCH_TEMPLATE
Analytics
* MATOMO_ANALYTICS_TEMPLATE, MATOMO_ANALYTICS_URL,
MATOMO_ANALYTICS_SITE_ID - only if analytics="matomo"
and this is not a local-development deployment.
Branding
* THEME_FRONTPAGE, THEME_LOGO, THEME_FRONTPAGE_LOGO
* THEME_SITENAME, THEME_FRONTPAGE_TITLE,
THEME_SHOW_FRONTPAGE_INTRO_SECTION
Repository metadata (SEO & front page)
* REPOSITORY_NAME, REPOSITORY_DESCRIPTION,
REPOSITORY_SUPPORT_CONTACT, REPOSITORY_SUBTITLE,
REPOSITORY_KEYWORDS
Build pipeline
* JAVASCRIPT_PACKAGES_MANAGER, ASSETS_BUILDER,
WEBPACKEXT_NPM_PKG_CLS, WEBPACKEXT_PROJECT
Records & deposit UI
* RECORDS_UI_ENDPOINTS,
APP_RDM_DEPOSIT_NG_FILES_UI_ENABLED,
DASHBOARD_RECORD_CREATE_URL
* APP_RDM_DETAIL_SIDE_BAR_TEMPLATES
Search UI
* THEME_SEARCH_ENDPOINT, SEARCH_UI_SEARCH_VIEW
Source code in oarepo_config/ui.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
configure_vocabulary(code: str, **kwargs: Any) -> None
Declare a custom controlled vocabulary (a fixed list of allowed values).
Vocabularies are controlled lists of values that records can pick from, such as languages, resource types or licenses. Call this once for each additional vocabulary type your repository needs, to describe it and any extra properties it should have.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
A short, unique identifier for the vocabulary, e.g.
|
required |
**kwargs
|
Any
|
Extra details describing the vocabulary, typically
including |
{}
|
Calling this multiple times with different code values adds
multiple vocabularies; it does not replace previously configured
ones.
Invenio configuration variables set:
INVENIO_VOCABULARY_TYPE_METADATA- the entry forcodeis set tokwargs; entries for other vocabulary codes (added by earlier calls) are kept.
Example
Source code in oarepo_config/vocabulary.py
configure_workflows(*workflow_definitions: BaseWorkflowSettings, default_individual_workflow: str = 'individual', default_community_workflow: str = 'community', context: dict | None = None) -> list[Workflow]
Set up workflows based on the provided workflow definitions.
This function is intended to be called from within invenio.cfg and will create a "WORKFLOWS" entry in the invenio.cfg context (in the caller's globals).
Example
# invenio.cfg
from oarepo_app.config import (
configure_workflows,
IndividualWorkflow,
CommunityWorkflow,
)
configure_workflows(
IndividualWorkflow(
authenticated_draft_creation=False,
review_required=True,
publish_without_review=False,
),
CommunityWorkflow(),
)
# no need to assign the result to WORKFLOWS, that is done automatically
If the workflow definitions are empty, a permissive IndividualWorkflow will be created (authenticated draft creation, publish without review allowed).
If there is no IndividualWorkflow definition in the workflow definitions (but there are other workflow types), a restricted IndividualWorkflow (no deposition allowed) will be created with default settings.
The default_individual_workflow parameter should be the code of the workflow to use as the default one for individual deposits, where no community is involved and the workflow code is not provided by the caller.
If the context is provided, the "WORKFLOWS" entry will be added to it instead of the caller's globals.
See https://nrp-cz.github.io/docs/customize/workflows for more information on how to customize the workflows.
Source code in oarepo_config/workflows/simplified/__init__.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
register_workflow(workflow_code: str, workflow_name: str | LazyString, permissions_policy: str | type, requests_policy: str | type, use_low_level_workflows: bool = False) -> None
Register a submission/review workflow that records can go through.
A workflow defines the path a record takes from being created to being published - for example, who may create it, whether it needs review/approval before publishing, and who may perform each of those steps. This adds one such workflow to the repository, so that it can be selected when configuring where records may be submitted (e.g. a community).
This is a low-level, single-workflow building block. Repositories
that use the community-based workflow shape provided by the
oarepo_app package typically use its higher-level
configure_workflows(IndividualWorkflow(...), CommunityWorkflow(...))
helper instead - see this package's README for the difference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow_code
|
str
|
A short, unique identifier for the workflow, e.g.
|
required |
workflow_name
|
str | LazyString
|
The human-readable name of the workflow, shown to
users, e.g. |
required |
permissions_policy
|
str | type
|
Who is allowed to do what with records that use this workflow (create, edit, delete, publish, ...). Pass either a permissions policy class or its import path as a string. |
required |
requests_policy
|
str | type
|
What review/approval requests are available for records using this workflow (e.g. a publish request that needs a curator's approval). Pass either a request policy class or its import path as a string. |
required |
use_low_level_workflows
|
bool
|
Set to |
False
|
Requires the optional oarepo_workflows (and, for its defaults,
oarepo_requests) package to be installed.
Invenio configuration variables set:
WORKFLOWS- the new workflow is appended; workflows already registered (by earlier calls) are kept.REQUESTS_PERMISSION_POLICY- only if not already set by an earlier call; defaults tooarepo_config.requests.RequestsPermissionPolicy(workflow-based, plus creation of community-topic request types).
Example
from oarepo_workflows.services.permissions import (
DefaultWorkflowPermissions,
)
from oarepo_requests.services.permissions.workflow_policies import (
CreatorsFromWorkflowRequestsPermissionPolicy,
)
config.register_workflow(
workflow_code="default",
workflow_name=_("Default workflow"),
permissions_policy=DefaultWorkflowPermissions,
requests_policy=CreatorsFromWorkflowRequestsPermissionPolicy,
)
Source code in oarepo_config/workflows/low_level.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |