feat: implement module-driven context providers for dynamic page context
Introduces a module-driven context provider system that allows modules to dynamically contribute template context variables without hardcoding imports. Key changes: - Add context_providers field to ModuleDefinition in app/modules/base.py - Create unified get_context_for_frontend() that queries enabled modules only - Add context providers to CMS module (PLATFORM, STOREFRONT) - Add context providers to billing module (PLATFORM) - Fix SQLAlchemy cross-module relationship resolution (Order, AdminMenuConfig, MarketplaceImportJob) by ensuring models are imported before referencing - Document the entire system in docs/architecture/module-system.md Benefits: - Zero coupling: adding/removing modules requires no route handler changes - Lazy loading: module code only imported when that module is enabled - Per-platform customization: each platform loads only what it needs - Graceful degradation: one failing module doesn't break entire page Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,14 @@ Usage:
|
||||
)
|
||||
"""
|
||||
|
||||
# Import models from other modules FIRST to resolve string-based relationship references.
|
||||
# These imports are NOT re-exported, just ensure models are registered with SQLAlchemy
|
||||
# before the marketplace models are loaded.
|
||||
#
|
||||
# Relationship being resolved:
|
||||
# - LetzshopFulfillmentQueue.order -> "Order" (in orders module)
|
||||
from app.modules.orders.models import Order # noqa: F401
|
||||
|
||||
from app.modules.marketplace.models.marketplace_product import (
|
||||
MarketplaceProduct,
|
||||
ProductType,
|
||||
|
||||
Reference in New Issue
Block a user