one registry per pgroup

This commit is contained in:
2026-05-03 00:19:45 +02:00
parent a8c6adc28c
commit c72d78faf1
+6 -8
View File
@@ -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)