lakesuperior package

class lakesuperior.Env[source]

Bases: object

Lakesuperior environment.

Instances of this class contain the environment necessary to run a self-standing instance of Lakesuperior in a Python environment.

setup(config_dir=None, config=None)[source]

Set the environment up.

This must be done before using the application.

This method will warn and not do anything if it has already been called in the same runtime environment,

Parameters:
  • config_dir (str) – Path to a directory containing the configuration .yml files. If this and config are omitted, the configuration files are read from the default directory defined in parse_config().
  • config (dict) – Fully-formed configuration as a dictionary. If this is provided, config_dir is ignored. This is useful to call parse_config() separately and modify the configuration manually before passing it to the setup.
lakesuperior.basedir = '/home/docs/checkouts/readthedocs.org/user_builds/lakesuperior/envs/latest/lib/python3.6/site-packages/lakesuperior-1.0.0a23-py3.6-linux-x86_64.egg/lakesuperior'

Base directory for the module.

This can be used by modules looking for configuration and data files to be referenced or copied with a known path relative to the package root.

Return type:str
lakesuperior.env = <lakesuperior.Env object>

A pox on “globals are evil”.

Object for storing global variables. Different environments (e.g. webapp, test suite) put the appropriate value in it. The most important values to be stored are app_conf (either from lakesuperior.config_parser.config or lakesuperior.config_parser.test_config) and app_globals (obtained by an instance of lakesuperior.globals.AppGlobals).

e.g.:

>>> from lakesuperior import env
>>> env.setup()

Or, with a custom configuration directory:

>>> from lakesuperior import env
>>> env.setup('/my/config/dir')

Or, to load a configuration and modify it before setting up the environment:

>>> from lakesuperior import env
>>> from lakesuperior.config_parser import parse_config
>>> config = parse_config(config_dir)
>>> config['application']['data_dir'] = '/data/ext/mystore'
>>> env.setup(config=config)
Return type:Object
lakesuperior.thread_env = <_thread._local object>

Thread-local environment.

This is used to store thread-specific variables such as start/end request timestamps.

Return type:threading.local

Subpackages

Submodules

lakesuperior.app module

lakesuperior.app.create_app(app_conf)[source]

App factory.

Create a Flask app.

@param app_conf (dict) Configuration parsed from application.yml file.

lakesuperior.config_parser module

lakesuperior.config_parser.default_config_dir = '/home/docs/checkouts/readthedocs.org/user_builds/lakesuperior/envs/latest/lib/python3.6/site-packages/lakesuperior-1.0.0a23-py3.6-linux-x86_64.egg/lakesuperior/etc.defaults'

Default configuration directory.

This value falls back to the provided etc.defaults directory if the FCREPO_CONFIG_DIR environment variable is not set.

This value can still be overridden by custom applications by passing the config_dir value to parse_config() explicitly.

lakesuperior.config_parser.parse_config(config_dir=None)[source]

Parse configuration from a directory.

This is normally called by the standard endpoints (lsup_admin, web server, etc.) or by a Python client by importing lakesuperior.env.setup() but an application using a non-default configuration may specify an alternative configuration directory.

The directory must have the same structure as the one provided in etc.defaults.

Parameters:config_dir – Location on the filesystem of the configuration directory. The default is set by the FCREPO_CONFIG_DIR environment variable or, if this is not set, the etc.defaults stock directory.

lakesuperior.env_setup module

Default configuration.

Import this module to initialize the configuration for a production setup:

>>> import lakesuperior.env_setup

Will load the default configuration.

Note: this will be deprecated because it’s just as easy to do the same with

::
>>> import env # which in most cases is imported anyways
>>> env.setup()

lakesuperior.exceptions module

Put all exceptions here.

exception lakesuperior.exceptions.ChecksumValidationError(uid, prov_cksum, calc_cksum, msg=None)[source]

Bases: lakesuperior.exceptions.ResourceError

Raised in an attempt to create a resource a URI that already exists and is not supposed to.

This usually surfaces at the HTTP level as a 409.

exception lakesuperior.exceptions.IncompatibleLdpTypeError(uid, mimetype, msg=None)[source]

Bases: lakesuperior.exceptions.ResourceError

Raised when a LDP-NR resource is PUT in place of a LDP-RS and vice versa.

This usually surfaces at the HTTP level as a 415.

exception lakesuperior.exceptions.IndigestibleError(uid, msg=None)[source]

Bases: lakesuperior.exceptions.ResourceError

Raised when an unsupported digest algorithm is requested.

exception lakesuperior.exceptions.InvalidResourceError(uid, msg=None)[source]

Bases: lakesuperior.exceptions.ResourceError

Raised when an invalid resource is found.

This usually surfaces at the HTTP level as a 409 or other error.

exception lakesuperior.exceptions.InvalidTripleError(t)[source]

Bases: ValueError

Raised when a triple in a delta is not valid.

This does not necessarily that it is not valid RDF, but rather that it may not be valid for the context it is meant to be utilized.

exception lakesuperior.exceptions.PathSegmentError(uid, msg=None)[source]

Bases: lakesuperior.exceptions.ResourceError

Raised when a LDP-NR resource is a path segment.

This may be an expected result and may be handled to return a 200.

exception lakesuperior.exceptions.RdfParsingError(fmt, parser_msg='')[source]

Bases: ValueError

Raised when a string cannot be parsed as RDF in the given format.

exception lakesuperior.exceptions.RefIntViolationError(o)[source]

Bases: RuntimeError

Raised when a provided data set has a link to a non-existing repository resource. With some setups this is handled silently, with a strict setting it raises this exception that should return a 412 HTTP code.

exception lakesuperior.exceptions.ResourceError(uid, msg=None)[source]

Bases: RuntimeError

Raised in an attempt to create a resource a URI that already exists and is not supposed to.

This usually surfaces at the HTTP level as a 409.

exception lakesuperior.exceptions.ResourceExistsError(uid, msg=None)[source]

Bases: lakesuperior.exceptions.ResourceError

Raised in an attempt to create a resource a URI that already exists and is not supposed to.

This usually surfaces at the HTTP level as a 409.

exception lakesuperior.exceptions.ResourceNotExistsError(uid, msg=None)[source]

Bases: lakesuperior.exceptions.ResourceError

Raised in an attempt to create a resource a URN that does not exist and is supposed to.

This usually surfaces at the HTTP level as a 404.

exception lakesuperior.exceptions.ServerManagedTermError(terms, term_type=None)[source]

Bases: RuntimeError

Raised in an attempt to change a triple containing a server-managed term.

This usually surfaces at the HTTP level as a 409 or other error.

exception lakesuperior.exceptions.SingleSubjectError(uid, subject)[source]

Bases: RuntimeError

Raised when a SPARQL-Update query or a RDF payload for a PUT contain subjects that do not correspond to the resource being operated on.

exception lakesuperior.exceptions.TombstoneError(uid, ts)[source]

Bases: RuntimeError

Raised when a tombstone resource is found.

It is up to the caller to handle this which may be a benign and expected result.

lakesuperior.globals module

lakesuperior.lsup_admin module

Utility to perform core maintenance tasks via console command-line.

The command-line tool is self-documented. Type:

lsup-admin --help

for a list of tools and options.

lakesuperior.migrator module

class lakesuperior.migrator.Migrator(src, dest, src_auth=(None, None), clear=False, zero_binaries=False, compact_uris=False, skip_errors=False)[source]

Bases: object

Class to handle a database migration.

This class holds state of progress and shared variables as it crawls through linked resources in an LDP server.

Since a repository migration can be a very long operation but it is impossible to know the number of the resources to gather by LDP interaction alone, a progress ticker outputs the number of processed resources at regular intervals.

db_params = {'map_size': 1099511627776, 'meminit': False, 'metasync': False, 'readahead': False}

LMDB database parameters.

See lmdb.Environment.__init__()

ignored_preds = (rdflib.term.URIRef('http://fedora.info/definitions/fcrepo#hasParent'), rdflib.term.URIRef('http://fedora.info/definitions/fcrepo#hasTransactionProvider'), rdflib.term.URIRef('http://fedora.info/definitions/fcrepo#hasFixityService'))

List of predicates to ignore when looking for links.

migrate(start_pts=None, list_file=None)[source]

Migrate the database.

This method creates a fully functional and configured Lakesuperior data set contained in a folder from an LDP repository.

Parameters:
  • start_pts (tuple or list) – List of starting points to retrieve resources from. It would typically be the repository root in case of a full dump or one or more resources in the repository for a partial one.
  • list_file (str) – path to a local file containing a list of URIs, one per line.
class lakesuperior.migrator.StoreWrapper(store)[source]

Bases: contextlib.ContextDecorator

Open and close a store.

lakesuperior.profiler module

lakesuperior.server module