From c72d78faf10b0402bd22b666c4ce889a4a00f02c Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sun, 3 May 2026 00:19:45 +0200 Subject: [PATCH] one registry per pgroup --- stand.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/stand.py b/stand.py index dfa6d2d..b4c5ff9 100755 --- a/stand.py +++ b/stand.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +from collections import defaultdict from datetime import datetime from typing import Annotated, Any @@ -26,7 +27,7 @@ lib = ac.get_library( router = APIRouter() -grids = Registry() +grids = defaultdict(Registry) OPTIONS = { @@ -62,9 +63,8 @@ def update_adb(evt): def update_grids(evt): sender = evt.sender - for grid in grids: - if grid.options["context"]["pgroup"] != evt.args["context"]["pgroup"]: - continue + pgroup = evt.args["context"]["pgroup"] + for grid in grids[pgroup]: grid.set_cell_server(evt) if grid == sender: # the sender is already up-to-date @@ -93,7 +93,7 @@ def page(pgroup: PGroup): grid.classes("h-[calc(100vh-2rem)]") # full height minus padding grid.on("cellValueChanged", update_adb) grid.on("cellValueChanged", update_grids) - grids.add(grid) + grids[pgroup].add(grid) @router.post("/{pgroup}/append/") @@ -107,9 +107,7 @@ def append(pgroup: PGroup, row: dict[str, Any]): row = {"index": now, **row} # setdefault would not force index to be the first column res = [] - for grid in grids: - if grid.options["context"]["pgroup"] != pgroup: - continue + for grid in grids[pgroup]: grid.append(row) res.append(grid.options)