Add widget debug logging to post context processor
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 49s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-19 19:29:07 +00:00
parent 4f6e5d234d
commit 7ec38b87f8

View File

@@ -69,16 +69,25 @@ def register():
db_post_id = (g.post_data.get("post") or {}).get("id") db_post_id = (g.post_data.get("post") or {}).get("id")
post_slug = (g.post_data.get("post") or {}).get("slug", "") post_slug = (g.post_data.get("post") or {}).get("slug", "")
# Widget-driven container nav — only include widgets with data # Widget-driven container nav
import logging
_log = logging.getLogger("coop")
_log.warning("WIDGET DEBUG: %d nav widgets registered, post_id=%s slug=%s",
len(widgets.container_nav), db_post_id, post_slug)
container_nav_loaded = [] container_nav_loaded = []
for w in widgets.container_nav: for w in widgets.container_nav:
wctx = await w.context_fn( try:
g.s, container_type="page", container_id=db_post_id, wctx = await w.context_fn(
post_slug=post_slug, g.s, container_type="page", container_id=db_post_id,
) post_slug=post_slug,
# Include widget if it has any list data )
if any(v for v in wctx.values() if isinstance(v, list) and v): has_data = any(v for v in wctx.values() if isinstance(v, list) and v)
container_nav_loaded.append({"widget": w, "ctx": wctx}) _log.warning("WIDGET DEBUG: %s has_data=%s keys=%s", w.domain, has_data,
{k: len(v) if isinstance(v, list) else v for k, v in wctx.items()})
if has_data:
container_nav_loaded.append({"widget": w, "ctx": wctx})
except Exception as e:
_log.exception("WIDGET ERROR: %s: %s", w.domain, e)
ctx = { ctx = {
**p_data, **p_data,