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

@@ -4,8 +4,8 @@ from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from models.calendars import Calendar
from shared.models.ghost_content import Post # for FK existence checks
from glue.services.relationships import attach_child, detach_child
from shared.services.registry import services
from shared.services.relationships import attach_child, detach_child
import unicodedata
import re
@@ -49,13 +49,15 @@ def slugify(value: str, max_len: int = 255) -> str:
async def soft_delete(sess: AsyncSession, post_slug: str, calendar_slug: str) -> bool:
post = await services.blog.get_post_by_slug(sess, post_slug)
if not post:
return False
cal = (
await sess.execute(
select(Calendar)
.join(Post, Calendar.container_id == Post.id)
.where(Calendar.container_type == "page")
.where(
Post.slug == post_slug,
select(Calendar).where(
Calendar.container_type == "page",
Calendar.container_id == post.id,
Calendar.slug == calendar_slug,
Calendar.deleted_at.is_(None),
)
@@ -82,7 +84,7 @@ async def create_calendar(sess: AsyncSession, post_id: int, name: str) -> Calend
slug=slugify(name)
# Ensure post exists (avoid silent FK errors in some DBs)
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 CalendarError(f"Post {post_id} does not exist.")