Files
rose-ash/market/bp/page_markets/routes.py
giles 293f7713d6
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 16s
Auto-mount defpages: eliminate Python route stubs across all 9 services
Defpages are now declared with absolute paths in .sx files and auto-mounted
directly on the Quart app, removing ~850 lines of blueprint mount_pages calls,
before_request hooks, and g.* wrapper boilerplate. A new page = one defpage
declaration, nothing else.

Infrastructure:
- async_eval awaits coroutine results from callable dispatch
- auto_mount_pages() mounts all registered defpages on the app
- g._defpage_ctx pattern passes helper data to layout context

Migrated: sx, account, orders, federation, cart, market, events, blog

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 19:03:15 +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 sx.sx_components import render_page_markets_cards
post_slug = post.get("slug", "")
sx_src = await render_page_markets_cards(markets, has_more, page, post_slug)
return sx_response(sx_src)
return bp