A utility package for dash apps
Project description
Dash utilities
dash_utils
This module containes convient methods to typical dash related methods:
Timezone related
To make the client timezone available in callbacks, invoke the following during you setup
init_client_tz_javascript(dashappp)
This adds a small snippet of javascript, which sets a cookie with the timezone. After this, a couple of functions
has been implemented to conveniently deal with datetime
objects such as
get_client_tz()
to_client_tz(dt)
format_client_date()
parse_client_date()
Notice the two last functions uses dash_utils.CLIENT_DATE_FORMAT
which defaults to %Y-%m-%d %H:%M:%S
.
Dash callback related
Two functions to deal with the trigger source of a callback has also been implemented
was_source(id_str)
get_source()
keycloak_utils
This module implements some convenient functions when integrating with dash-keycloak and dealing with roles.
Firstly, one should set the client in keycloak_utils.KEYCLOAK_CLIENT
.
It is now possible to check if a user has a given role or even decorate a flask route to abort with 401 if the user does not have a role from a given list.
check_role("admin")
@require_role(["READ", "WRITE"])
@app.route('/api/status', methods=["GET"])
def do_stuff():
...
Read and write
A small scheme to determine read and write access has also been implemented. In this scheme a user can have either READ or WRITE access to a subject.
The role names is thus defined as <subject>/READ
, <subject>/WRITE
or <subject>/ALL
.
The admin
role has special privileges, i.e. both READ and WRITE for all subjects.
A users access for a subject can now be checked with
has_read_access(subject)
has_read_write(subject)
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
File details
Details for the file ems-dash-utils-0.0.1.tar.gz
.
File metadata
- Download URL: ems-dash-utils-0.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f76db4931c6bfb7ae3112faea368308325eb673411f9034dc561dafd43cdf80 |
|
MD5 | 218a1252de0accf272b95b8c6e952e8b |
|
BLAKE2b-256 | 51ca60031fefd414f037e591c8c340512c3df64ea274519c5aaf157c108f2c28 |