seamm_datastore package

Subpackages

Submodules

seamm_datastore.connect module

Class and functions for connection to database.

class seamm_datastore.connect.SEAMMDatastore(database_uri: str = 'sqlite:///:memory:', initialize: bool = False, permissions: dict = None, username: str = None, password: str = None, datastore_location: str = None, default_project: str = 'default')[source]

Bases: object

add_job(id, flowchart_filename, project_names=['default'], path=None, title='', description='', submitted=None, started=None, finished=None, parameters=None, status='submitted')[source]
current_user()[source]
finish_job(job_id, finish_time, status='finished')[source]

Set the status and time that the job finished.

Parameters:
  • job_id (int) – The ID of the job, eg. 209

  • finish_time (datetime.datetime) – The UTC time when the job finished.

  • status (str) – The status, such as “error” or the default, “finished”

  • as_json (bool = False) – Ignored

  • current_user (str or User = None) – Ignored

Returns:

True if the finish time was successfully set, False otherwise.

Return type:

bool

import_datastore(*args, **kwargs)[source]
login(username, password)[source]
logout()[source]
class seamm_datastore.connect.current_app(config)[source]

Bases: object

Fake current_app

seamm_datastore.connect.login_required(method)[source]

Decorator for actions requiring current user

seamm_datastore.connect.manage_session(function)[source]

Decorator for closing sqlalchemy sessions when attached to SEAMMDatastore class.

seamm_datastore.connect.session_scope(session)[source]

Provide a transactional scope around a series of operations.

seamm_datastore.flask_authorize_patch module

Patch for flask_authorize.

Flask authorize and the functions defined here can only be used with an application context.

class seamm_datastore.flask_authorize_patch.AccessControlPermissionsMixin[source]

Bases: PermissionsMixin

classmethod authorized(check)[source]

Query operator for permissions mixins. This operator can be used in SQLAlchemy query statements, and will automatically decorate queries with appropriate owner/group and permissionc checks.

Arguments:

check (str): Permission to authorize (i.e. read, update)

Examples:

Query all articles where the current user is read-authorized:

Article.query.filter(Article.authorized('read')).all()

Query by multiple parameters, including authorization:

Article.query.filter(or_(
    Article.name.contains('open article'),
    Article.authorized('read')
))
seamm_datastore.flask_authorize_patch.generate_association_table(entity_name, resource_name, entity_tablename=None, resource_tablename=None)[source]

seamm_datastore.util module

Util Functions and classes

exception seamm_datastore.util.LoginRequiredError[source]

Bases: Exception

exception seamm_datastore.util.NotAuthorizedError[source]

Bases: Exception

Module contents

seamm_datastore The database models for the seamm datastore

seamm_datastore.connect

alias of SEAMMDatastore