Remove render_to_sx from public API: enforce sx_call for all service code
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m44s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m44s
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>
This commit is contained in:
@@ -57,9 +57,9 @@ async def _post_header_sx(ctx: dict, page_post: Any, *, oob: bool = False) -> st
|
||||
return await _shared_post_header_sx(ctx, oob=oob)
|
||||
|
||||
|
||||
async def _cart_header_sx(ctx: dict, *, oob: bool = False) -> str:
|
||||
from shared.sx.helpers import render_to_sx, call_url
|
||||
return await render_to_sx(
|
||||
def _cart_header_sx(ctx: dict, *, oob: bool = False) -> str:
|
||||
from shared.sx.helpers import sx_call, call_url
|
||||
return sx_call(
|
||||
"menu-row-sx",
|
||||
id="cart-row", level=1, colour="sky",
|
||||
link_href=call_url(ctx, "cart_url", "/"),
|
||||
@@ -68,15 +68,15 @@ async def _cart_header_sx(ctx: dict, *, oob: bool = False) -> str:
|
||||
)
|
||||
|
||||
|
||||
async def _page_cart_header_sx(ctx: dict, page_post: Any, *, oob: bool = False) -> str:
|
||||
from shared.sx.helpers import render_to_sx, call_url
|
||||
def _page_cart_header_sx(ctx: dict, page_post: Any, *, oob: bool = False) -> str:
|
||||
from shared.sx.helpers import sx_call, call_url
|
||||
slug = page_post.slug if page_post else ""
|
||||
title = ((page_post.title if page_post else None) or "")[:160]
|
||||
label_sx = await render_to_sx("cart-page-label",
|
||||
label_sx = sx_call("cart-page-label",
|
||||
feature_image=page_post.feature_image if page_post else None,
|
||||
title=title)
|
||||
nav_sx = await render_to_sx("cart-all-carts-link", href=call_url(ctx, "cart_url", "/"))
|
||||
return await render_to_sx(
|
||||
nav_sx = sx_call("cart-all-carts-link", href=call_url(ctx, "cart_url", "/"))
|
||||
return sx_call(
|
||||
"menu-row-sx",
|
||||
id="page-cart-row", level=2, colour="sky",
|
||||
link_href=call_url(ctx, "cart_url", f"/{slug}/"),
|
||||
@@ -102,8 +102,8 @@ async def _cart_page_full(ctx: dict, **kw: Any) -> str:
|
||||
page_post = ctx.get("page_post")
|
||||
env = {}
|
||||
return await render_to_sx_with_env("cart-page-layout-full", env,
|
||||
cart_row=SxExpr(await _cart_header_sx(ctx)),
|
||||
page_cart_row=SxExpr(await _page_cart_header_sx(ctx, page_post)),
|
||||
cart_row=SxExpr(_cart_header_sx(ctx)),
|
||||
page_cart_row=SxExpr(_page_cart_header_sx(ctx, page_post)),
|
||||
)
|
||||
|
||||
|
||||
@@ -113,8 +113,8 @@ async def _cart_page_oob(ctx: dict, **kw: Any) -> str:
|
||||
env = {}
|
||||
return await render_to_sx_with_env("cart-page-layout-oob", env,
|
||||
root_header_oob=SxExpr(await root_header_sx(ctx, oob=True)),
|
||||
cart_row_oob=SxExpr(await _cart_header_sx(ctx, oob=True)),
|
||||
page_cart_row=SxExpr(await _page_cart_header_sx(ctx, page_post)),
|
||||
cart_row_oob=SxExpr(_cart_header_sx(ctx, oob=True)),
|
||||
page_cart_row=SxExpr(_page_cart_header_sx(ctx, page_post)),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user