Files
rose-ash/market/bp/page_markets/routes.py
giles 959e63d440
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m44s
Remove render_to_sx from public API: enforce sx_call for all service code
Replace ~250 render_to_sx calls across all services with sync sx_call,
converting many async functions to sync where no other awaits remained.
Make render_to_sx/render_to_sx_with_env private (_render_to_sx).
Add (post-header-ctx) IO primitive and shared post/post-admin defmacros.
Convert built-in post/post-admin layouts from Python to register_sx_layout
with .sx defcomps. Remove dead post_admin_mobile_nav_sx.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 19:30:45 +00:00

39 lines
1.1 KiB
Python

"""
Page-markets blueprint — shows markets for a single page.
Mounted at /<slug> (page-scoped). Requires g.post_data from hydrate_post.
GET / handled by defpage. GET /page-markets is pagination fragment.
"""
from __future__ import annotations
from quart import Blueprint, g, request
from shared.sx.helpers import sx_response
from shared.services.registry import services
async def _load_markets(post_id, page, per_page=20):
"""Load markets for this page's container."""
markets, has_more = await services.market.list_marketplaces(
g.s, "page", post_id, page=page, per_page=per_page,
)
return markets, has_more
def register() -> Blueprint:
bp = Blueprint("page_markets", __name__)
@bp.get("/page-markets")
async def markets_fragment():
post = g.post_data["post"]
page = int(request.args.get("page", 1))
markets, has_more = await _load_markets(post["id"], page)
from sxc.pages.renders import render_page_markets_cards
post_slug = post.get("slug", "")
sx_src = render_page_markets_cards(markets, has_more, page, post_slug)
return sx_response(sx_src)
return bp