From 25228881aa2b977a3dcd4ec8ab1a1d3bc88e47bc Mon Sep 17 00:00:00 2001 From: giles Date: Tue, 24 Feb 2026 10:12:00 +0000 Subject: [PATCH] Fix product slug: extract from URL path instead of g.post_slug App-level preprocessor pops slug then page_slug into g.post_slug, overwriting the product slug with the page slug ("market"). Extract the product slug directly from the request path after "/product/". Co-Authored-By: Claude Opus 4.6 --- bp/product/routes.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bp/product/routes.py b/bp/product/routes.py index 959ce5f..ef8d0a2 100644 --- a/bp/product/routes.py +++ b/bp/product/routes.py @@ -25,9 +25,17 @@ def register(): bp = Blueprint("product", __name__, url_prefix="/product/") @bp.url_value_preprocessor def pull_blog(endpoint, values): - # App-level preprocessor pops "slug" into g.post_slug before this runs, - # so values.get("slug") is None. Fall back to g.post_slug. - g.product_slug = values.get("slug") or getattr(g, "post_slug", None) + # App-level preprocessor pops both "slug" and "page_slug" into g.post_slug, + # with page_slug overwriting slug. We need the original product slug which + # the app preprocessor popped first — but it's gone. Instead, extract the + # product slug from the request path: .../product//... + from quart import request as req + parts = req.path.rstrip("/").split("/") + try: + idx = parts.index("product") + g.product_slug = parts[idx + 1] if idx + 1 < len(parts) else None + except (ValueError, IndexError): + g.product_slug = None # ───────────────────────────────────────────────────────────── # BEFORE REQUEST: Slug or numeric ID resolver