Import all app model packages at startup for SQLAlchemy mapper
Cross-domain relationships like Product.order_items → OrderItem use string references that SQLAlchemy resolves by class name lookup. All model packages must be imported so every class is registered before mapper configuration runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,14 @@ from typing import Callable, Awaitable, Sequence
|
||||
from quart import Quart, request, g, send_from_directory
|
||||
|
||||
from shared.config import init_config, config, pretty
|
||||
from shared.models import KV # ensure models imported
|
||||
from shared.models import KV # ensure shared models imported
|
||||
# Register all app model classes with SQLAlchemy so cross-domain
|
||||
# relationship() string references resolve correctly.
|
||||
for _mod in ("blog.models", "market.models", "cart.models", "events.models"):
|
||||
try:
|
||||
__import__(_mod)
|
||||
except ImportError:
|
||||
pass
|
||||
from shared.log_config import configure_logging
|
||||
from shared.events import EventProcessor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user