ckanext-doi
Gives every CKAN dataset a DOI (Digital Object Identifier) through DataCite, so it can be cited in publications.
The DOI is reserved as soon as the dataset is created, and registered
with DataCite - resolvable at https://doi.org/<prefix>/<id> - once the
dataset is active and public. A draft or private dataset keeps its
DOI unregistered: you can quote it in a paper under embargo, it starts
resolving the day the dataset is published. Its metadata (title,
creators, dates, size, formats...) is sent again to DataCite whenever it
changes.
Fork of NaturalHistoryMuseum/ckanext-doi, maintained by Phen-ICS (CNRS/IGBMC) for the FAIR3R catalogue. Published on PyPI as
ckanext-fair3r-doi; the plugin is still calleddoi.
What this fork changes
- CKAN 2.12 (SQLAlchemy 2.0, Python 3.12), with upstream's Alembic
migration for its table (
ckan db upgrade -p doi). - Test mode links work: in test mode, DOI links go to DataCite's test
resolver (
handle.test.datacite.org), since test DOIs don't exist on doi.org. - Cleaner metadata: ISO 8601 dates, the size in a readable unit (and
left out rather than "0 kb"), contributors kept apart from creators, and
the DOI pointing at
ckanext.doi.site_urlwhen set. - Clearer errors: a public dataset without an author is a form error on the author field, not a server error.
- Only datasets get DOIs: other package types (harvest sources, pages...) are left alone.
- Organization bulk actions (make public, private, delete) carry on past a dataset that fails.
ckan doi update-doiskips private and deleted datasets and carries on past errors, instead of stopping at the first one.- French translation, and CI that tests, builds and publishes to PyPI on every merge.
Requirements
- CKAN 2.12.
- A DataCite repository account: a test account (DataCite Fabrica test) for development, a live one to register real DOIs. Each has its own credentials and prefix.
Installation
-
Install the package in CKAN's virtualenv:
pip install ckanext-fair3r-doi
-
Enable the plugin in
ckan.ini:ckan.plugins = ... doi
-
Configure your DataCite account (see Configuration):
ckanext.doi.account_name = ABC.DEFG ckanext.doi.account_password = <password> ckanext.doi.prefix = 10.1234 ckanext.doi.publisher = My Institute ckanext.doi.test_mode = true
-
Create its table:
ckan -c /path/to/ckan.ini db upgrade -p doi
-
Restart CKAN. Make a dataset public: the page shows "DataCite DOI created" and the DOI appears in its citation.
Configuration
| Setting | Required | Meaning |
|---|---|---|
ckanext.doi.account_name |
yes | DataCite repository account, e.g. ABC.DEFG |
ckanext.doi.account_password |
yes | Its password |
ckanext.doi.prefix |
yes | The account's DOI prefix, e.g. 10.1234 (the test account has its own) |
ckanext.doi.publisher |
yes | Institution publishing the DOIs |
ckanext.doi.test_mode |
yes | true: DataCite's test system (DOIs never resolve on doi.org); false: live DOIs |
ckanext.doi.site_url |
no | Base URL the DOI points to; defaults to ckan.site_url |
ckanext.doi.site_title |
no | Site name used in the citation |
Which fields go to DataCite
DataCite Metadata Schema 4.5
(4.2 with an older datacite library). The required ones:
| DataCite | From |
|---|---|
title |
dataset title |
creator |
dataset author (one or more) |
publisher |
ckanext.doi.publisher |
publicationYear |
year the dataset was created (metadata_created) |
resourceType |
dataset type |
Everything else (description, dates, sizes, formats, subjects...) is
mapped in lib/metadata.py. Other plugins
can add to or change it through the IDoi interface (below) - this is
how ckanext-fair3r sends its
FDF metadata (ORCID, ROR, genes, organisms...).
Commands
| Command | Use |
|---|---|
ckan doi update-doi [-p <dataset id> ...] |
Send the current metadata of all (or the given) published DOIs to DataCite again, e.g. after a change in the mapping. Skips private and deleted datasets, and up-to-date ones |
ckan doi delete-dois |
Delete every DOI from CKAN's own table - not from DataCite (registered DOIs are permanent) |
Templates
Citation snippets, for your own templates:
{% snippet "doi/snippets/package_citation.html", pkg_dict=g.pkg_dict %}
{% snippet "doi/snippets/resource_citation.html", pkg_dict=g.pkg_dict, res=res %}
Extending: the IDoi interface
A plugin implementing ckanext.doi.interfaces.IDoi can change the
metadata before it is sent. Both methods run after this extension's own,
in plugin order.
| Method | Use |
|---|---|
build_metadata_dict(pkg_dict, metadata_dict, errors) |
Fill or change metadata_dict from the dataset; remove from errors the required fields you handled. Returns (metadata_dict, errors). Any required field still in errors afterwards stops the DOI with a DOIMetadataException |
build_xml_dict(metadata_dict, xml_dict) |
Change the dict given to the datacite library's schema tostring() / validate(). Returns xml_dict |
Tests
docker exec -u ckan -it ckan-app pytest --ckan-ini=/plugins/ckanext-doi/test.ini /plugins/ckanext-doi/ckanext/doi/tests
The DataCite API is mocked: no network or account needed. Always pass
--ckan-ini: the fixtures empty the database they run against, and refuse
to run unless its name contains test.
Credits and license
Originally written by the Natural History Museum,
London. Released under the GNU General Public License v3.0 or later - see
LICENSE.
Metadata
Release files for ckanext-fair3r-doi 3.3.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ckanext_fair3r_doi-3.3.19.tar.gz | 50.9 kB | Without provenance | Details for ckanext_fair3r_doi-3.3.19.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ckanext_fair3r_doi-3.3.19-py3-none-any.whl | Python 3 | none | any | Details for ckanext_fair3r_doi-3.3.19-py3-none-any.whl |
Total release size: 110.9 kB
Release files / ckanext_fair3r_doi-3.3.19.tar.gz
| Download URL | ckanext_fair3r_doi-3.3.19.tar.gz |
|---|---|
| Size | 50.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
082e80972708e75136bdd882fb393d9d25eb7df8cd353c21c15cb2242de49322
|
|
BLAKE2b-256 checksum How to use checksums |
5526556946ea8f0623e10bec053ff827830bb96ea167570f81de4f743a5cf795
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / ckanext_fair3r_doi-3.3.19-py3-none-any.whl
| Download URL | ckanext_fair3r_doi-3.3.19-py3-none-any.whl |
|---|---|
| Size | 60.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fa1ee7dcf1bc95082e06a5ea3044cd635b32f4a438cd3df25cb02c018848368
|
|
BLAKE2b-256 checksum How to use checksums |
ba843fd73732f0731701cb23600a2a262fdac3738c33c0d138e647a5337fac47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Security for ckanext-fair3r-doi 3.3.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.