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:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from shared.sx.helpers import render_to_sx
|
||||
from shared.sx.helpers import sx_call
|
||||
|
||||
from .utils import _clear_deeper_oob, _ensure_container_nav
|
||||
from .calendar import (
|
||||
@@ -235,8 +235,8 @@ async def _cal_admin_full(ctx: dict, **kw: Any) -> str:
|
||||
return await render_to_sx_with_env("events-cal-admin-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
admin_header=SxExpr(await post_admin_header_sx(ctx, slug, selected="calendars")),
|
||||
calendar_header=SxExpr(await _calendar_header_sx(ctx)),
|
||||
calendar_admin_header=SxExpr(await _calendar_admin_header_sx(ctx)),
|
||||
calendar_header=SxExpr(_calendar_header_sx(ctx)),
|
||||
calendar_admin_header=SxExpr(_calendar_admin_header_sx(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -247,9 +247,9 @@ async def _cal_admin_oob(ctx: dict, **kw: Any) -> str:
|
||||
slug = (ctx.get("post") or {}).get("slug", "")
|
||||
return await render_to_sx_with_env("events-cal-admin-layout-oob", {},
|
||||
admin_oob=SxExpr(await post_admin_header_sx(ctx, slug, oob=True, selected="calendars")),
|
||||
cal_oob=SxExpr(await _calendar_header_sx(ctx, oob=True)),
|
||||
cal_oob=SxExpr(_calendar_header_sx(ctx, oob=True)),
|
||||
cal_admin_oob_wrap=SxExpr(await oob_header_sx("calendar-header-child",
|
||||
"calendar-admin-header-child", await _calendar_admin_header_sx(ctx))),
|
||||
"calendar-admin-header-child", _calendar_admin_header_sx(ctx))),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"post-admin-row", "post-admin-header-child",
|
||||
"calendar-row", "calendar-header-child",
|
||||
@@ -270,7 +270,7 @@ async def _slots_oob(ctx: dict, **kw: Any) -> str:
|
||||
slug = (ctx.get("post") or {}).get("slug", "")
|
||||
return await render_to_sx_with_env("events-slots-layout-oob", {},
|
||||
admin_oob=SxExpr(await post_admin_header_sx(ctx, slug, oob=True, selected="calendars")),
|
||||
cal_admin_oob=SxExpr(await _calendar_admin_header_sx(ctx, oob=True)),
|
||||
cal_admin_oob=SxExpr(_calendar_admin_header_sx(ctx, oob=True)),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"post-admin-row", "post-admin-header-child",
|
||||
"calendar-row", "calendar-header-child",
|
||||
@@ -288,9 +288,9 @@ async def _slot_full(ctx: dict, **kw: Any) -> str:
|
||||
return await render_to_sx_with_env("events-slot-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
admin_header=SxExpr(await post_admin_header_sx(ctx, slug, selected="calendars")),
|
||||
calendar_header=SxExpr(await _calendar_header_sx(ctx)),
|
||||
calendar_admin_header=SxExpr(await _calendar_admin_header_sx(ctx)),
|
||||
slot_header=SxExpr(await _slot_header_html(ctx)),
|
||||
calendar_header=SxExpr(_calendar_header_sx(ctx)),
|
||||
calendar_admin_header=SxExpr(_calendar_admin_header_sx(ctx)),
|
||||
slot_header=SxExpr(_slot_header_html(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -301,9 +301,9 @@ async def _slot_oob(ctx: dict, **kw: Any) -> str:
|
||||
slug = (ctx.get("post") or {}).get("slug", "")
|
||||
return await render_to_sx_with_env("events-slot-layout-oob", {},
|
||||
admin_oob=SxExpr(await post_admin_header_sx(ctx, slug, oob=True, selected="calendars")),
|
||||
cal_admin_oob=SxExpr(await _calendar_admin_header_sx(ctx, oob=True)),
|
||||
cal_admin_oob=SxExpr(_calendar_admin_header_sx(ctx, oob=True)),
|
||||
slot_oob_wrap=SxExpr(await oob_header_sx("calendar-admin-header-child",
|
||||
"slot-header-child", await _slot_header_html(ctx))),
|
||||
"slot-header-child", _slot_header_html(ctx))),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"post-admin-row", "post-admin-header-child",
|
||||
"calendar-row", "calendar-header-child",
|
||||
@@ -322,9 +322,9 @@ async def _day_admin_full(ctx: dict, **kw: Any) -> str:
|
||||
return await render_to_sx_with_env("events-day-admin-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
admin_header=SxExpr(await post_admin_header_sx(ctx, slug, selected="calendars")),
|
||||
calendar_header=SxExpr(await _calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(await _day_header_sx(ctx)),
|
||||
day_admin_header=SxExpr(await _day_admin_header_sx(ctx)),
|
||||
calendar_header=SxExpr(_calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(_day_header_sx(ctx)),
|
||||
day_admin_header=SxExpr(_day_admin_header_sx(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -335,9 +335,9 @@ async def _day_admin_oob(ctx: dict, **kw: Any) -> str:
|
||||
slug = (ctx.get("post") or {}).get("slug", "")
|
||||
return await render_to_sx_with_env("events-day-admin-layout-oob", {},
|
||||
admin_oob=SxExpr(await post_admin_header_sx(ctx, slug, oob=True, selected="calendars")),
|
||||
cal_oob=SxExpr(await _calendar_header_sx(ctx, oob=True)),
|
||||
cal_oob=SxExpr(_calendar_header_sx(ctx, oob=True)),
|
||||
day_admin_oob_wrap=SxExpr(await oob_header_sx("day-header-child",
|
||||
"day-admin-header-child", await _day_admin_header_sx(ctx))),
|
||||
"day-admin-header-child", _day_admin_header_sx(ctx))),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"post-admin-row", "post-admin-header-child",
|
||||
"calendar-row", "calendar-header-child",
|
||||
@@ -353,9 +353,9 @@ async def _entry_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.parser import SxExpr
|
||||
return await render_to_sx_with_env("events-entry-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
calendar_header=SxExpr(await _calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(await _day_header_sx(ctx)),
|
||||
entry_header=SxExpr(await _entry_header_html(ctx)),
|
||||
calendar_header=SxExpr(_calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(_day_header_sx(ctx)),
|
||||
entry_header=SxExpr(_entry_header_html(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -363,9 +363,9 @@ async def _entry_oob(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import render_to_sx_with_env, oob_header_sx
|
||||
from shared.sx.parser import SxExpr
|
||||
return await render_to_sx_with_env("events-entry-layout-oob", {},
|
||||
day_oob=SxExpr(await _day_header_sx(ctx, oob=True)),
|
||||
day_oob=SxExpr(_day_header_sx(ctx, oob=True)),
|
||||
entry_oob_wrap=SxExpr(await oob_header_sx("day-header-child",
|
||||
"entry-header-child", await _entry_header_html(ctx))),
|
||||
"entry-header-child", _entry_header_html(ctx))),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"calendar-row", "calendar-header-child",
|
||||
"day-row", "day-header-child",
|
||||
@@ -383,10 +383,10 @@ async def _entry_admin_full(ctx: dict, **kw: Any) -> str:
|
||||
return await render_to_sx_with_env("events-entry-admin-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
admin_header=SxExpr(await post_admin_header_sx(ctx, slug, selected="calendars")),
|
||||
calendar_header=SxExpr(await _calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(await _day_header_sx(ctx)),
|
||||
entry_header=SxExpr(await _entry_header_html(ctx)),
|
||||
entry_admin_header=SxExpr(await _entry_admin_header_html(ctx)),
|
||||
calendar_header=SxExpr(_calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(_day_header_sx(ctx)),
|
||||
entry_header=SxExpr(_entry_header_html(ctx)),
|
||||
entry_admin_header=SxExpr(_entry_admin_header_html(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -397,9 +397,9 @@ async def _entry_admin_oob(ctx: dict, **kw: Any) -> str:
|
||||
slug = (ctx.get("post") or {}).get("slug", "")
|
||||
return await render_to_sx_with_env("events-entry-admin-layout-oob", {},
|
||||
admin_oob=SxExpr(await post_admin_header_sx(ctx, slug, oob=True, selected="calendars")),
|
||||
entry_oob=SxExpr(await _entry_header_html(ctx, oob=True)),
|
||||
entry_oob=SxExpr(_entry_header_html(ctx, oob=True)),
|
||||
entry_admin_oob_wrap=SxExpr(await oob_header_sx("entry-header-child",
|
||||
"entry-admin-header-child", await _entry_admin_header_html(ctx))),
|
||||
"entry-admin-header-child", _entry_admin_header_html(ctx))),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"post-admin-row", "post-admin-header-child",
|
||||
"calendar-row", "calendar-header-child",
|
||||
@@ -416,11 +416,11 @@ async def _ticket_types_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.parser import SxExpr
|
||||
return await render_to_sx_with_env("events-ticket-types-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
calendar_header=SxExpr(await _calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(await _day_header_sx(ctx)),
|
||||
entry_header=SxExpr(await _entry_header_html(ctx)),
|
||||
entry_admin_header=SxExpr(await _entry_admin_header_html(ctx)),
|
||||
ticket_types_header=SxExpr(await _ticket_types_header_html(ctx)),
|
||||
calendar_header=SxExpr(_calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(_day_header_sx(ctx)),
|
||||
entry_header=SxExpr(_entry_header_html(ctx)),
|
||||
entry_admin_header=SxExpr(_entry_admin_header_html(ctx)),
|
||||
ticket_types_header=SxExpr(_ticket_types_header_html(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -428,9 +428,9 @@ async def _ticket_types_oob(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import render_to_sx_with_env, oob_header_sx
|
||||
from shared.sx.parser import SxExpr
|
||||
return await render_to_sx_with_env("events-ticket-types-layout-oob", {},
|
||||
entry_admin_oob=SxExpr(await _entry_admin_header_html(ctx, oob=True)),
|
||||
entry_admin_oob=SxExpr(_entry_admin_header_html(ctx, oob=True)),
|
||||
ticket_types_oob_wrap=SxExpr(await oob_header_sx("entry-admin-header-child",
|
||||
"ticket_types-header-child", await _ticket_types_header_html(ctx))),
|
||||
"ticket_types-header-child", _ticket_types_header_html(ctx))),
|
||||
)
|
||||
|
||||
|
||||
@@ -441,12 +441,12 @@ async def _ticket_type_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.parser import SxExpr
|
||||
return await render_to_sx_with_env("events-ticket-type-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
calendar_header=SxExpr(await _calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(await _day_header_sx(ctx)),
|
||||
entry_header=SxExpr(await _entry_header_html(ctx)),
|
||||
entry_admin_header=SxExpr(await _entry_admin_header_html(ctx)),
|
||||
ticket_types_header=SxExpr(await _ticket_types_header_html(ctx)),
|
||||
ticket_type_header=SxExpr(await _ticket_type_header_html(ctx)),
|
||||
calendar_header=SxExpr(_calendar_header_sx(ctx)),
|
||||
day_header=SxExpr(_day_header_sx(ctx)),
|
||||
entry_header=SxExpr(_entry_header_html(ctx)),
|
||||
entry_admin_header=SxExpr(_entry_admin_header_html(ctx)),
|
||||
ticket_types_header=SxExpr(_ticket_types_header_html(ctx)),
|
||||
ticket_type_header=SxExpr(_ticket_type_header_html(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -454,9 +454,9 @@ async def _ticket_type_oob(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import render_to_sx_with_env, oob_header_sx
|
||||
from shared.sx.parser import SxExpr
|
||||
return await render_to_sx_with_env("events-ticket-type-layout-oob", {},
|
||||
ticket_types_oob=SxExpr(await _ticket_types_header_html(ctx, oob=True)),
|
||||
ticket_types_oob=SxExpr(_ticket_types_header_html(ctx, oob=True)),
|
||||
ticket_type_oob_wrap=SxExpr(await oob_header_sx("ticket_types-header-child",
|
||||
"ticket_type-header-child", await _ticket_type_header_html(ctx))),
|
||||
"ticket_type-header-child", _ticket_type_header_html(ctx))),
|
||||
)
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ async def _markets_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.parser import SxExpr
|
||||
return await render_to_sx_with_env("events-markets-layout-full", {},
|
||||
post_header=SxExpr(await _post_header_sx(ctx)),
|
||||
markets_header=SxExpr(await _markets_header_sx(ctx)),
|
||||
markets_header=SxExpr(_markets_header_sx(ctx)),
|
||||
)
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ async def _markets_oob(ctx: dict, **kw: Any) -> str:
|
||||
return await render_to_sx_with_env("events-markets-layout-oob", {},
|
||||
post_oob=SxExpr(await _post_header_sx(ctx, oob=True)),
|
||||
markets_oob_wrap=SxExpr(await oob_header_sx("post-header-child",
|
||||
"markets-header-child", await _markets_header_sx(ctx))),
|
||||
"markets-header-child", _markets_header_sx(ctx))),
|
||||
)
|
||||
|
||||
|
||||
@@ -510,14 +510,14 @@ async def _h_calendar_admin_content(calendar_slug=None, **kw):
|
||||
await _ensure_calendar(calendar_slug)
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _calendar_admin_main_panel_html(ctx)
|
||||
return _calendar_admin_main_panel_html(ctx)
|
||||
|
||||
|
||||
async def _h_day_admin_content(calendar_slug=None, year=None, month=None, day=None, **kw):
|
||||
await _ensure_calendar(calendar_slug)
|
||||
if year is not None:
|
||||
await _ensure_day_data(int(year), int(month), int(day))
|
||||
return await _day_admin_main_panel_html({})
|
||||
return _day_admin_main_panel_html({})
|
||||
|
||||
|
||||
async def _h_slots_content(calendar_slug=None, **kw):
|
||||
@@ -527,7 +527,7 @@ async def _h_slots_content(calendar_slug=None, **kw):
|
||||
from bp.slots.services.slots import list_slots as svc_list_slots
|
||||
slots = await svc_list_slots(g.s, calendar.id) if calendar else []
|
||||
_add_to_defpage_ctx(slots=slots)
|
||||
return await render_slots_table(slots, calendar)
|
||||
return render_slots_table(slots, calendar)
|
||||
|
||||
|
||||
async def _h_slot_content(calendar_slug=None, slot_id=None, **kw):
|
||||
@@ -540,7 +540,7 @@ async def _h_slot_content(calendar_slug=None, slot_id=None, **kw):
|
||||
g.slot = slot
|
||||
_add_to_defpage_ctx(slot=slot)
|
||||
calendar = getattr(g, "calendar", None)
|
||||
return await render_slot_main_panel(slot, calendar)
|
||||
return render_slot_main_panel(slot, calendar)
|
||||
|
||||
|
||||
async def _h_entry_content(calendar_slug=None, entry_id=None, **kw):
|
||||
@@ -548,7 +548,7 @@ async def _h_entry_content(calendar_slug=None, entry_id=None, **kw):
|
||||
await _ensure_entry_context(entry_id)
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _entry_main_panel_html(ctx)
|
||||
return _entry_main_panel_html(ctx)
|
||||
|
||||
|
||||
async def _h_entry_menu(calendar_slug=None, entry_id=None, **kw):
|
||||
@@ -556,7 +556,7 @@ async def _h_entry_menu(calendar_slug=None, entry_id=None, **kw):
|
||||
await _ensure_entry_context(entry_id)
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _entry_nav_html(ctx)
|
||||
return _entry_nav_html(ctx)
|
||||
|
||||
|
||||
async def _h_entry_admin_content(calendar_slug=None, entry_id=None, **kw):
|
||||
@@ -564,12 +564,11 @@ async def _h_entry_admin_content(calendar_slug=None, entry_id=None, **kw):
|
||||
await _ensure_entry_context(entry_id)
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _entry_admin_main_panel_html(ctx)
|
||||
return _entry_admin_main_panel_html(ctx)
|
||||
|
||||
|
||||
async def _h_admin_menu():
|
||||
from shared.sx.helpers import render_to_sx
|
||||
return await render_to_sx("events-admin-placeholder-nav")
|
||||
def _h_admin_menu():
|
||||
return sx_call("events-admin-placeholder-nav")
|
||||
|
||||
|
||||
async def _h_ticket_types_content(calendar_slug=None, entry_id=None,
|
||||
@@ -582,7 +581,7 @@ async def _h_ticket_types_content(calendar_slug=None, entry_id=None,
|
||||
from bp.ticket_types.services.tickets import list_ticket_types as svc_list_ticket_types
|
||||
ticket_types = await svc_list_ticket_types(g.s, entry.id) if entry else []
|
||||
_add_to_defpage_ctx(ticket_types=ticket_types)
|
||||
return await render_ticket_types_table(ticket_types, entry, calendar, day, month, year)
|
||||
return render_ticket_types_table(ticket_types, entry, calendar, day, month, year)
|
||||
|
||||
|
||||
async def _h_ticket_type_content(calendar_slug=None, entry_id=None,
|
||||
@@ -598,7 +597,7 @@ async def _h_ticket_type_content(calendar_slug=None, entry_id=None,
|
||||
_add_to_defpage_ctx(ticket_type=ticket_type)
|
||||
entry = getattr(g, "entry", None)
|
||||
calendar = getattr(g, "calendar", None)
|
||||
return await render_ticket_type_main_panel(ticket_type, entry, calendar, day, month, year)
|
||||
return render_ticket_type_main_panel(ticket_type, entry, calendar, day, month, year)
|
||||
|
||||
|
||||
async def _h_tickets_content(**kw):
|
||||
@@ -613,7 +612,7 @@ async def _h_tickets_content(**kw):
|
||||
)
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _tickets_main_panel_html(ctx, tickets)
|
||||
return _tickets_main_panel_html(ctx, tickets)
|
||||
|
||||
|
||||
async def _h_ticket_detail_content(code=None, **kw):
|
||||
@@ -635,7 +634,7 @@ async def _h_ticket_detail_content(code=None, **kw):
|
||||
abort(404)
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _ticket_detail_panel_html(ctx, ticket)
|
||||
return _ticket_detail_panel_html(ctx, ticket)
|
||||
|
||||
|
||||
async def _h_ticket_admin_content(**kw):
|
||||
@@ -674,10 +673,10 @@ async def _h_ticket_admin_content(**kw):
|
||||
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _ticket_admin_main_panel_html(ctx, tickets, stats)
|
||||
return _ticket_admin_main_panel_html(ctx, tickets, stats)
|
||||
|
||||
|
||||
async def _h_markets_content(**kw):
|
||||
from shared.sx.page import get_template_context
|
||||
ctx = await get_template_context()
|
||||
return await _markets_main_panel_html(ctx)
|
||||
return _markets_main_panel_html(ctx)
|
||||
|
||||
Reference in New Issue
Block a user