Sure, trying to give a small reproduceable piece:
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.CERULEAN], title='MyApp')
server = app.server
app.config.suppress_callback_exceptions = True
def serve_layout():
return html.Div([
dcc.Location(id='url'),
html.Div(id='page-content')
])
from myapp import MyApp
app.layout = serve_layout
t = MyApp()
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/time-series':
return t.app()
@app.callback(
[Output("popover", "is_open")],
[Input("popover-target", "n_clicks")]
)
def combined_popover(n_click_popover, n_click_submit, close_select_click, close_modal_click, close_interval_warning,
is_open, relayout_data, radioitem_value, tags_dropdown_value):
new_tag = tag.Tag(tag_type, tag_class, start_date, end_date)
t.add_tag(t.sensor_id, new_tag)
In MyApp class:
def app(self):
layout = html.Div([
dbc.Row(dbc.Col(self.nav)),
dbc.Row(dbc.Col(self.header)),
dbc.Row(dbc.Col(dcc.Loading(id='loading-graph', children=[self.graphs, self.graph],
type='circle'))),
dbc.Row([dbc.Col(self.tags), dbc.Col(self.alerts_card)])
], style={'padding': 10})
return layout
def add_tag(self, sensor_id, tag):
v_id = self.reference[self.reference.SensorId == sensor_id].VId.values[0]
position = self.reference[self.reference.SensorId == sensor_id].Position.values[0]
data = {'SensorId': sensor_id, 'EventStartDateTime': tag.start, 'EventEndDateTime': tag.end,
'EventType': tag.tag_type, 'VId': vid, 'Position': position,
'Class': tag.class}
self.tags_pd = self.tags_pd.append(data, ignore_index=True)
So eventually all class members for the object t are shared among all clients, and in this example for instance tags_pd is the same for all clients, although I would like them to be independent between sessions/users. Does this explain a bit better?