No project description provided
Project description
seamm_datastore
This repository contains the SQLAlchemy models for the SEAMM datastore as well as some associated utilities such as dumping to JSON and checking permissions. These database models and permissions system were developed to be used inside a flask application context in the SEAMM Dashboard. However, you may use this package as a stand-alone (outside of flask) with limited permissions capabilities.
Quickstart
This package contains SQLAlchemy models for the SEAMM datastore. The following gives an example of how to connect to a database in memory. You can switch the database by providing a different database URI.
import seamm_datastore
# Create a database session
connection = seamm_datastore.SEAMMDatastore("sqlite:///:memory:", initialize=True, username="your_username", password="your_password")
The SEAMMDatastore
class has associated functions which can be used to add to the database using the same permission system that the seamm dashboard uses. Use the .add_job
method to add a job and get_jobs
to get all of the jobs the user is authorized to view.
To retrieve all the users and dump the info to JSON:
from seamm_datastore.database.schema import JobSchema
# Create user schema
users = JobSchema(many=True)
# To retrieve all users in db
all_jobs = connection.get_jobs()
users_json = users.dump(all_jobs)
Permissions
The SEAMM datastore has a permissions system built in using flask-authorize for authorization. This provides a "permissions" entry on each resource table (Jobs, Flowcharts, and Projects) where permissions for "owner", "group" and "world". The SEAMM datastore also has capabilities to set "special permissions" for users or groups on specific projects.
Permissions are not automatically enforced when working directly with database models. In the SEAMM Dashboard, permissions are enforced with authentication (verifying the user is who they say they are) using [flask-jwt-extended] and authorization using flask-authorize.
To use the permissions checking mechanisms of flask authorize outside of a flask app, use the helper function here seamm_datastore.SEAMMDatastore
.
Copyright
Copyright (c) 2021, Jessica A. Nash (The Molecular Sciences Software Institute)
Acknowledgements
Project based on the Computational Molecular Science Python Cookiecutter version 1.5.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for seamm_datastore-2021.10.20.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eac4be7229ef69dbbc6899f0664ea06594a2c4f449592905daf1b077461f501 |
|
MD5 | 463635936d26e684c2a92af396e2a41f |
|
BLAKE2b-256 | a92e4e4405de66bac597bdaed748797baa847a8f19eba0f07fd23603ecf64320 |
Hashes for seamm_datastore-2021.10.20-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2cb5e25cc988c09ec99daf5da6f5dbd47b9a8321efa667ae48db56026224be5 |
|
MD5 | a634324445fa1ce0e6f3b75e128613d2 |
|
BLAKE2b-256 | 3bc93001f49c395cfe28f84039d6162d200a1ab0a1b9bc8008004ef9f24ab30a |