Fix product slug resolution: fall back to g.post_slug
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 55s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 55s
App-level url_value_preprocessor pops slug into g.post_slug before the blueprint preprocessor runs, leaving values empty. Fall back to g.post_slug so resolve_product and cart route get the slug. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,9 @@ def register():
|
|||||||
bp = Blueprint("product", __name__, url_prefix="/product/<slug>")
|
bp = Blueprint("product", __name__, url_prefix="/product/<slug>")
|
||||||
@bp.url_value_preprocessor
|
@bp.url_value_preprocessor
|
||||||
def pull_blog(endpoint, values):
|
def pull_blog(endpoint, values):
|
||||||
g.product_slug = values.get("slug")
|
# 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)
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
# ─────────────────────────────────────────────────────────────
|
||||||
# BEFORE REQUEST: Slug or numeric ID resolver
|
# BEFORE REQUEST: Slug or numeric ID resolver
|
||||||
|
|||||||
Reference in New Issue
Block a user