Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

DCTerms support for OARepo (just selected props)

Project description

OARepo DC data model

image image image image

DC Terms data model for oarepo.

Instalation

    pip install oarepo-dc

Usage

The library provides Dublin Core object for json schema with marshmallow validation and deserialization and elastic search mapping.

JSON Schema

Add this package to your dependencies and use it via $ref in json schema as "[server]/schemas/dcterms-v2.0.0.json#/definitions/DCObject". Elastic Search mapping is handled automatically via Eleastic Search templates.

Usage example

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "these": {
            "$ref": "https://localhost:5000/schemas/dcterms-v2.0.0.json#/definitions/DCObject"
      }
  }
}
{
  "type": "object",
  "properties": {
    "these": {
        "abstract" : {"cs": "neco", "en": "something"}, 
        "contributor" : "Alzbeta Pokorna", 
        "modified":"2012-04-23T18:25:43.511Z"
            }
        }
}

Marshmallow

For data validation and deserialization.

If marshmallow validation is performed within application context, languages in multilingual string data fields are validated against SUPPORTED_LANGUAGES config. If the validation is performed outside app context, the keys are not checked against a list of languages but a generic validation is performed - keys must be in ISO 639-1 or language-region format from RFC 5646.

Usage example

class MD(DCObjectSchemaV2Mixin, marshmallow.Schema):
    pass

data = {"title": {"cs": "neco"},
                 "alternative": {"en-us": "something", "cs": "neco"},
                 "abstract": {},
                 "creator": "Alzbeta Pokorna",
                 "contributor": "Miroslav Simek",
                 "dateSubmitted": "1970-10-12",
                 "available": "1970-03-18",
                 "created": "1970-09-29",
                 "modified": "1970-12-31",
                 "description": {"en-us": "something", "cs": "neco"},
                 "identifier": "id"}


    MD().load(data)

Supported languages validation

You can specified supported languages in your application configuration in SUPPORTED_LANGUAGES . Then only these languages are allowed as multilingual string. You must specified your languages in format "en" or "en-us".

Usage example

app.config.update(SUPPORTED_LANGUAGES = ["cs", "en"])

Changes

Version 2.0.0 (released 2020-08-25)

  • Initial public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for oarepo-dc, version 2.1.0
Filename, size File type Python version Upload date Hashes
Filename, size oarepo_dc-2.1.0-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size oarepo_dc-2.1.0.tar.gz (7.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page