Domain isolation: replace cross-domain imports with service calls
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 55s

Replace direct Post, MarketPlace, Calendar model queries and HTTP API
calls with typed service calls. Events registers all 4 services via
domain_services_fn with has() guards.

Key changes:
- app.py: use domain_services_fn, Post/Calendar/MarketPlace queries
  → services.blog/calendar/market, HTTP cart API → services.cart
- calendars/markets services: Post → services.blog
- post_associations: Post → services.blog, direct queries → services
- markets routes: remove unused MarketPlace import
- glue imports → shared imports throughout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-19 04:30:20 +00:00
parent 7b15f37686
commit f1b5aeac53
7 changed files with 82 additions and 89 deletions

View File

@@ -3,9 +3,6 @@ from __future__ import annotations
from quart import (
request, render_template, make_response, Blueprint, g
)
from sqlalchemy import select
from shared.models.market_place import MarketPlace
from .services.markets import (
create_market as svc_create_market,

View File

@@ -7,9 +7,9 @@ from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from shared.models.market_place import MarketPlace
from shared.models.ghost_content import Post
from shared.browser.app.utils import utcnow
from glue.services.relationships import attach_child, detach_child
from shared.services.registry import services
from shared.services.relationships import attach_child, detach_child
class MarketError(ValueError):
@@ -40,7 +40,7 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
raise MarketError("Market name must not be empty.")
slug = slugify(name)
post = (await sess.execute(select(Post).where(Post.id == post_id))).scalar_one_or_none()
post = await services.blog.get_post_by_id(sess, post_id)
if not post:
raise MarketError(f"Post {post_id} does not exist.")
if not post.is_page:
@@ -68,13 +68,15 @@ async def create_market(sess: AsyncSession, post_id: int, name: str) -> MarketPl
async def soft_delete(sess: AsyncSession, post_slug: str, market_slug: str) -> bool:
post = await services.blog.get_post_by_slug(sess, post_slug)
if not post:
return False
market = (
await sess.execute(
select(MarketPlace)
.join(Post, MarketPlace.container_id == Post.id)
.where(MarketPlace.container_type == "page")
.where(
Post.slug == post_slug,
select(MarketPlace).where(
MarketPlace.container_type == "page",
MarketPlace.container_id == post.id,
MarketPlace.slug == market_slug,
MarketPlace.deleted_at.is_(None),
)