Replace sx_call() with render_to_sx() across all services
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m6s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m6s
Python no longer generates s-expression strings. All SX rendering now goes through render_to_sx() which builds AST from native Python values and evaluates via async_eval_to_sx() — no SX string literals in Python. - Add render_to_sx()/render_to_html() infrastructure in shared/sx/helpers.py - Add (abort status msg) IO primitive in shared/sx/primitives_io.py - Convert all 9 services: ~650 sx_call() invocations replaced - Convert shared helpers (root_header_sx, full_page_sx, etc.) to async - Fix likes service import bug (likes.models → models) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -129,7 +129,7 @@ def register():
|
||||
from sx.sx_components import render_like_toggle_button
|
||||
|
||||
if not g.user:
|
||||
return sx_response(render_like_toggle_button(product_slug, False), status=403)
|
||||
return sx_response(await render_like_toggle_button(product_slug, False), status=403)
|
||||
|
||||
user_id = g.user.id
|
||||
|
||||
@@ -138,7 +138,7 @@ def register():
|
||||
})
|
||||
liked = result["liked"]
|
||||
|
||||
return sx_response(render_like_toggle_button(product_slug, liked))
|
||||
return sx_response(await render_like_toggle_button(product_slug, liked))
|
||||
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ def register():
|
||||
from sx.sx_components import render_cart_added_response
|
||||
item_data = getattr(g, "item_data", {})
|
||||
d = item_data.get("d", {})
|
||||
return sx_response(render_cart_added_response(g.cart, ci_ns, d))
|
||||
return sx_response(await render_cart_added_response(g.cart, ci_ns, d))
|
||||
|
||||
# normal POST: go to cart page
|
||||
from shared.infrastructure.urls import cart_url
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,55 +27,55 @@ def _register_market_layouts() -> None:
|
||||
register_custom_layout("market-admin", _market_admin_full, _market_admin_oob)
|
||||
|
||||
|
||||
def _market_full(ctx: dict, **kw: Any) -> str:
|
||||
async def _market_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import root_header_sx, header_child_sx
|
||||
from sx.sx_components import _post_header_sx, _market_header_sx
|
||||
|
||||
root_hdr = root_header_sx(ctx)
|
||||
child = "(<> " + _post_header_sx(ctx) + " " + _market_header_sx(ctx) + ")"
|
||||
return "(<> " + root_hdr + " " + header_child_sx(child) + ")"
|
||||
root_hdr = await root_header_sx(ctx)
|
||||
child = "(<> " + await _post_header_sx(ctx) + " " + await _market_header_sx(ctx) + ")"
|
||||
return "(<> " + root_hdr + " " + await header_child_sx(child) + ")"
|
||||
|
||||
|
||||
def _market_oob(ctx: dict, **kw: Any) -> str:
|
||||
async def _market_oob(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import oob_header_sx
|
||||
from sx.sx_components import _post_header_sx, _market_header_sx, _clear_deeper_oob
|
||||
|
||||
oobs = oob_header_sx("post-header-child", "market-header-child",
|
||||
_market_header_sx(ctx))
|
||||
oobs = "(<> " + oobs + " " + _post_header_sx(ctx, oob=True) + " "
|
||||
oobs = await oob_header_sx("post-header-child", "market-header-child",
|
||||
await _market_header_sx(ctx))
|
||||
oobs = "(<> " + oobs + " " + await _post_header_sx(ctx, oob=True) + " "
|
||||
oobs += _clear_deeper_oob("post-row", "post-header-child",
|
||||
"market-row", "market-header-child") + ")"
|
||||
return oobs
|
||||
|
||||
|
||||
def _market_mobile(ctx: dict, **kw: Any) -> str:
|
||||
async def _market_mobile(ctx: dict, **kw: Any) -> str:
|
||||
from sx.sx_components import _mobile_nav_panel_sx
|
||||
return _mobile_nav_panel_sx(ctx)
|
||||
return await _mobile_nav_panel_sx(ctx)
|
||||
|
||||
|
||||
def _market_admin_full(ctx: dict, **kw: Any) -> str:
|
||||
async def _market_admin_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import root_header_sx, header_child_sx
|
||||
from sx.sx_components import (
|
||||
_post_header_sx, _market_header_sx, _market_admin_header_sx,
|
||||
)
|
||||
|
||||
selected = kw.get("selected", "")
|
||||
root_hdr = root_header_sx(ctx)
|
||||
child = "(<> " + _post_header_sx(ctx) + " " + _market_header_sx(ctx) + " "
|
||||
child += _market_admin_header_sx(ctx, selected=selected) + ")"
|
||||
return "(<> " + root_hdr + " " + header_child_sx(child) + ")"
|
||||
root_hdr = await root_header_sx(ctx)
|
||||
child = "(<> " + await _post_header_sx(ctx) + " " + await _market_header_sx(ctx) + " "
|
||||
child += await _market_admin_header_sx(ctx, selected=selected) + ")"
|
||||
return "(<> " + root_hdr + " " + await header_child_sx(child) + ")"
|
||||
|
||||
|
||||
def _market_admin_oob(ctx: dict, **kw: Any) -> str:
|
||||
async def _market_admin_oob(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import oob_header_sx
|
||||
from sx.sx_components import (
|
||||
_market_header_sx, _market_admin_header_sx, _clear_deeper_oob,
|
||||
)
|
||||
|
||||
selected = kw.get("selected", "")
|
||||
oobs = "(<> " + _market_header_sx(ctx, oob=True) + " "
|
||||
oobs += oob_header_sx("market-header-child", "market-admin-header-child",
|
||||
_market_admin_header_sx(ctx, selected=selected)) + " "
|
||||
oobs = "(<> " + await _market_header_sx(ctx, oob=True) + " "
|
||||
oobs += await oob_header_sx("market-header-child", "market-admin-header-child",
|
||||
await _market_admin_header_sx(ctx, selected=selected)) + " "
|
||||
oobs += _clear_deeper_oob("post-row", "post-header-child",
|
||||
"market-row", "market-header-child",
|
||||
"market-admin-row", "market-admin-header-child") + ")"
|
||||
@@ -123,14 +123,14 @@ async def _h_all_markets_content(**kw):
|
||||
|
||||
if not markets:
|
||||
from sx.sx_components import _no_markets_sx
|
||||
return _no_markets_sx()
|
||||
return await _no_markets_sx()
|
||||
|
||||
prefix = route_prefix()
|
||||
next_url = prefix + url_for("all_markets.markets_fragment", page=page + 1)
|
||||
|
||||
from sx.sx_components import _market_cards_sx, _markets_grid
|
||||
cards = _market_cards_sx(markets, page_info, page, has_more, next_url)
|
||||
content = _markets_grid(cards)
|
||||
cards = await _market_cards_sx(markets, page_info, page, has_more, next_url)
|
||||
content = await _markets_grid(cards)
|
||||
return "(<> " + content + " " + '(div :class "pb-8")' + ")"
|
||||
|
||||
|
||||
@@ -148,15 +148,15 @@ async def _h_page_markets_content(slug=None, **kw):
|
||||
|
||||
if not markets:
|
||||
from sx.sx_components import _no_markets_sx
|
||||
return _no_markets_sx("No markets for this page")
|
||||
return await _no_markets_sx("No markets for this page")
|
||||
|
||||
prefix = route_prefix()
|
||||
next_url = prefix + url_for("page_markets.markets_fragment", page=page + 1)
|
||||
|
||||
from sx.sx_components import _market_cards_sx, _markets_grid
|
||||
cards = _market_cards_sx(markets, {}, page, has_more, next_url,
|
||||
cards = await _market_cards_sx(markets, {}, page, has_more, next_url,
|
||||
show_page_badge=False, post_slug=post_slug)
|
||||
content = _markets_grid(cards)
|
||||
content = await _markets_grid(cards)
|
||||
return "(<> " + content + " " + '(div :class "pb-8")' + ")"
|
||||
|
||||
|
||||
@@ -168,12 +168,12 @@ async def _h_page_admin_content(slug=None, **kw):
|
||||
return '(div :id "main-panel" ' + content + ')'
|
||||
|
||||
|
||||
def _h_market_home_content(page_slug=None, market_slug=None, **kw):
|
||||
async def _h_market_home_content(page_slug=None, market_slug=None, **kw):
|
||||
from quart import g
|
||||
post_data = getattr(g, "post_data", {})
|
||||
post = post_data.get("post", {})
|
||||
from sx.sx_components import _market_landing_content_sx
|
||||
return _market_landing_content_sx(post)
|
||||
return await _market_landing_content_sx(post)
|
||||
|
||||
|
||||
def _h_market_admin_content(page_slug=None, market_slug=None, **kw):
|
||||
|
||||
Reference in New Issue
Block a user