Skip to main content

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)

Release files for ems-dash-utils 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ems-dash-utils 0.0.1
File Size Uploaded
ems-dash-utils-0.0.1.tar.gz 3.4 kB Details

Release files / ems-dash-utils-0.0.1.tar.gz

Download URL ems-dash-utils-0.0.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5f76db4931c6bfb7ae3112faea368308325eb673411f9034dc561dafd43cdf80
BLAKE2b-256 checksum
How to use checksums
51ca60031fefd414f037e591c8c340512c3df64ea274519c5aaf157c108f2c28
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page