lakesuperior package

class lakesuperior.Env[source]

Bases: object

lakesuperior.basedir = '/home/docs/checkouts/readthedocs.org/user_builds/lakesuperior/envs/development/lib/python3.6/site-packages/lakesuperior-1.0.0a22-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”.

All-purpose bucket 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.config_parser import config
>>> from lakesuperior.globals import AppGlobals
>>> from lakesuperior import env
>>> env.app_globals = AppGlobals(config)

This is automated in non-test environments by importing lakesuperior.env_setup.

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/development/lib/python3.6/site-packages/lakesuperior-1.0.0a22-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.

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: RuntimeError

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.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

class lakesuperior.globals.AppGlobals(config)[source]

Bases: object

Application Globals.

This class is instantiated and used as a carrier for all connections and various global variables outside of the Flask app context.

The variables are set on initialization by passing a configuration dict. Usually this is done when starting an application. The instance with the loaded variables is then assigned to the lakesuperior.env global variable.

You can either load the default configuration:

>>>from lakesuperior import env_setup

Or set up an environment with a custom configuration:

>>> from lakesuperior import env
>>> from lakesuperior.app_globals import AppGlobals
>>> my_config = {'name': 'value', '...': '...'}
>>> env.app_globals = AppGlobals(my_config)
camelcase(word)[source]

Convert a string with underscores to a camel-cased one.

Ripped from https://stackoverflow.com/a/6425628

changelog
config

Global configuration.

This is a collection of all configuration options except for the WSGI configuration which is initialized at a different time and is stored under lakesuperior.env.wsgi_options.

TODO: Update class reference when interface will be separated from implementation.

messenger

Current message handler.

This is an instance of Messenger.

nonrdfly

Current non-RDF (binary contents) layout.

This is an instance of BaseNonRdfLayout.

rdf_store

Current RDF low-level store.

This is an instance of LmdbStore.

rdfly

Current RDF layout.

This is an instance of RsrcCentricLayout.

TODO: Update class reference when interface will be separated from implementation.

lakesuperior.globals.RES_CREATED = '_create_'

A resource was created.

lakesuperior.globals.RES_DELETED = '_delete_'

A resource was deleted.

lakesuperior.globals.RES_UPDATED = '_update_'

A resource was updated.

lakesuperior.globals.ROOT_RSRC_URI = rdflib.term.URIRef('info:fcres/')

Internal URI of root resource.

lakesuperior.globals.ROOT_UID = '/'

Root node UID.

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/v4/repository#hasParent'), rdflib.term.URIRef('http://fedora.info/definitions/v4/repository#hasTransactionProvider'), rdflib.term.URIRef('http://fedora.info/definitions/v4/repository#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.profiler.run()[source]

lakesuperior.server module

lakesuperior.server.run()[source]