-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsession.py
52 lines (37 loc) · 1.24 KB
/
session.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import typing
import streamlit as st
from streamlit.runtime.state import SessionStateProxy
from testgen.utils.singleton import Singleton
class TestgenSession(Singleton):
cookies_ready: bool
logging_in: bool
logging_out: bool
page_pending_cookies: st.Page
page_pending_login: str
page_pending_sidebar: str
page_args_pending_router: dict
current_page: str
current_page_args: dict
dbschema: str
name: str
username: str
authentication_status: bool
auth_role: typing.Literal["admin", "edit", "read"]
project: str
add_project: bool
sb_latest_rel: str
sb_schema_rev: str
def __init__(self, state: SessionStateProxy) -> None:
super().__setattr__("_state", state)
def __getattr__(self, key: str) -> typing.Any:
state = object.__getattribute__(self, "_state")
if key not in state:
return None
return state[key]
def __setattr__(self, key: str, value: typing.Any) -> None:
object.__getattribute__(self, "_state")[key] = value
def __delattr__(self, key: str) -> None:
state = object.__getattribute__(self, "_state")
if key in state:
del state[key]
session = TestgenSession(st.session_state)