dservercore

dserver Flask app

Functions

create_app([test_config])

Classes

ExtensionABC()

Any extension plugin must inherit from this base class.

PluginABC()

Common base class for all plugins.

RetrieveABC()

Any retrieve plugin must inherit from this base class.

SearchABC()

Any search plugin must inherit from this base class.

Exceptions

AuthenticationError

AuthorizationError

UnknownBaseURIError

UnknownURIError

ValidationError

exception dservercore.ValidationError

Bases: ValueError

__init__(*args, **kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception dservercore.AuthenticationError

Bases: ValueError

__init__(*args, **kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception dservercore.AuthorizationError

Bases: ValueError

__init__(*args, **kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception dservercore.UnknownBaseURIError

Bases: KeyError

__init__(*args, **kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception dservercore.UnknownURIError

Bases: KeyError

__init__(*args, **kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class dservercore.PluginABC

Bases: ABC

Common base class for all plugins.

There are different groups of plugins, i.e. search plugin, retrieve plugin, and extension plugins. These groups differ on where within this lookup server core they are hooked to. All of them are discovered via the python entrypoints mechanism.

Any plugin MUST implement a register_dataset method, and SHOULD implement a delete_dataset methods. While register_dataset is primarily intended to create new a dataset entry (but may as well replace an existing entry), the register_dataset is primarily intended to replace an existing entry (but may as well create a new entry). register_dataset MUST be idempotent. patch_update_dataset SHOULD update an existing entry partially by only modifying specified fields and MUST not create new entries. delete_dataset SHOULD remove a dataset entry from the plugin’s database if applicable.

abstract register_dataset(dataset_info: RegisterDatasetSchema)

Register or update a dataset entry by replacing a possibly existing entry. Idempotent.

The base URI is in the dataset_info. It is assumed that preflight checks have been made to ensure that the base URI has been registered and that the user has permissions to perform the action.

delete_dataset(dataset_uri: str)

Delete a dataset from the index by their URI.

get_config()

Return the Config object of the retrieve plugin.

get_config_secrets_to_obfuscate()

Return a list of config keys never to be exposed in clear text.

class dservercore.SearchABC

Bases: PluginABC

Any search plugin must inherit from this base class.

abstract search(query: SearchDatasetSchema, pagination_parameters: PaginationParameters = None, sort_parameters: SortParameters = None) <DatasetSchema(many=True)>

Search for datasets.

It is assumed that preflight checks have been made to ensure that the user has permissions to perform the action and that the base URIs in the query have been limited to those the user has permissions to search.

The search method is hooked into utils.search_datasets_by_user and MUST process a query argument adhering to SearchDatasetSchema, meaning

{
“base_uris”: [

“string”

], “free_text”: “string”, “uuids”: [

“string”

], “creator_usernames”: [

“string”

], “tags”: [

“string”

]

}

at the time of writing.

The search plugin SHOULD make use of “OR” logic for the items in “base_uris” and “creator_usernames” lists, but use “AND” logic for filtering the search based on the items in the tags list.

If pagination and sorting parameters are supplied, the plugin SHOULD provide the desired subset of datasets.

delete_dataset(dataset_uri: str)

Delete a dataset from the index by their URI.

get_config()

Return the Config object of the retrieve plugin.

get_config_secrets_to_obfuscate()

Return a list of config keys never to be exposed in clear text.

abstract register_dataset(dataset_info: RegisterDatasetSchema)

Register or update a dataset entry by replacing a possibly existing entry. Idempotent.

The base URI is in the dataset_info. It is assumed that preflight checks have been made to ensure that the base URI has been registered and that the user has permissions to perform the action.

class dservercore.RetrieveABC

Bases: ABC

Any retrieve plugin must inherit from this base class.

abstract get_readme(uri)

Return the dataset readme.

It is assumed that preflight checks have been made to ensure that the user has permissions to access the URI.

abstract get_manifest(uri)

Return the dataset manifest.

It is assumed that preflight checks have been made to ensure that the user has permissions to access the URI.

abstract get_annotations(uri)

Return the dataset annotations.

It is assumed that preflight checks have been made to ensure that the user has permissions to access the URI.

abstract get_tags(uri)

Return the dataset tags.

It is assumed that preflight checks have been made to ensure that the user has permissions to access the URI.

class dservercore.ExtensionABC

Bases: ABC

Any extension plugin must inherit from this base class.

An extension MUST implement:
  • a register_dataset(self, dataset_info) method.

  • a get_config() method.

  • a get_blueprint() method. This also means the extension MUST provide a single blueprint.

An extension MAY implement
  • an init_app(self, app, *args, **kwargs) method to be called from app factory.

The app factory will inject extension config parameters into the global Flask app config. An extension SHOULD hence:

  • prefix their config parameter keys uniquely, for example with their capitalized module name

  • retrieve config parameters in a Flask-typical fashion, i.e. from the environment or from file as done within the core at dservercore.config.Config

  • provide these parameters via the get_config method.

  • access at runtime via global Flask config, i.e. app.config

abstract get_blueprint()

Return the Flask blueprint to be used for the extension.

init_app(app, *args, **kwargs)

Called by Flask app factory.

dservercore.create_app(test_config=None)

Modules

dservercore.annotations_routes

Route for retrieving dataset annotations by URI.

dservercore.base_uri_routes

Routes for Base URI management

dservercore.blueprint

Custom dserver Blueprint

dservercore.cli

Command line utility functions.

dservercore.config

dserver Flask app configuration

dservercore.config_routes

Routes for retrieving server and server-side plugin configuration

dservercore.date_utils

Validation utility functions.

dservercore.extensions

Flask extensions

dservercore.manifest_routes

Route for retrieving the manifest of a dataset

dservercore.me_routes

Routes for me (information on currently authenticated user)

dservercore.readme_routes

Route for retrieving the readme of a dataset

dservercore.schemas

marshmallow schema for (de-) serialization and validation

dservercore.sort

Sort feature

dservercore.sql_models

Database models and derived schemas

dservercore.tags_routes

Route for retrieving tags of a dataset

dservercore.uri_routes

Routes for querying and managing dataset entries by their URIs

dservercore.user_routes

Routes for user management

dservercore.utils

Utility functions.

dservercore.utils_auth

Auth utility functions.

dservercore.uuid_routes

Routes for querying dataset entries by their UUIDs

dservercore.version