From f6cdf126e4b81708e0b5464804b9eaba372b07d5 Mon Sep 17 00:00:00 2001 From: giles Date: Wed, 25 Feb 2026 03:08:24 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20blog=20home=20route=20=E2=80=94=20replace?= =?UTF-8?q?=20services.cart=20with=20fetch=5Fdata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Missed cross-app call in blog/bp/blog/routes.py:127 caused CartService not registered error on blog.rose-ash.com homepage. Co-Authored-By: Claude Opus 4.6 --- blog/bp/blog/routes.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/blog/bp/blog/routes.py b/blog/bp/blog/routes.py index e6a6336..7d823b5 100644 --- a/blog/bp/blog/routes.py +++ b/blog/bp/blog/routes.py @@ -84,7 +84,8 @@ def register(url_prefix, title): from ..post.services.post_data import post_data as _post_data from shared.config import config as get_config from shared.infrastructure.cart_identity import current_cart_identity - from shared.services.registry import services as svc + from shared.infrastructure.data_client import fetch_data + from shared.contracts.dtos import CartSummaryDTO, dto_from_dict from shared.infrastructure.fragments import fetch_fragment, fetch_fragments p_data = await _post_data("home", g.s, include_drafts=False) @@ -121,13 +122,16 @@ def register(url_prefix, title): "container_nav_html": container_nav_html, } - # Page cart badge + # Page cart badge via HTTP if p_data["post"].get("is_page"): ident = current_cart_identity() - page_summary = await svc.cart.cart_summary( - g.s, user_id=ident["user_id"], session_id=ident["session_id"], - page_slug=post_slug, - ) + summary_params = {"page_slug": post_slug} + if ident["user_id"] is not None: + summary_params["user_id"] = ident["user_id"] + if ident["session_id"] is not None: + summary_params["session_id"] = ident["session_id"] + raw_summary = await fetch_data("cart", "cart-summary", params=summary_params, required=False) + page_summary = dto_from_dict(CartSummaryDTO, raw_summary) if raw_summary else CartSummaryDTO() ctx["page_cart_count"] = page_summary.count + page_summary.calendar_count + page_summary.ticket_count ctx["page_cart_total"] = float(page_summary.total + page_summary.calendar_total + page_summary.ticket_total)