Files
syops/backend/app/api/user/__init__.py

47 lines
1.3 KiB
Python

"""
api/user/__init__.py
用途:导出用户域与认证域 Blueprint,并维护历史测试替身兼容入口。
依赖:handlers、auth 及其共享认证操作。
逻辑:register_blueprints 将两个 Blueprint 挂载到 `/api/user`;兼容代理确保迁包前的替身点仍然生效。
"""
from __future__ import annotations
import sys
from types import ModuleType
from . import handlers
from . import auth
from .auth import auth_bp
user_bp = handlers.user_bp
# The documented Wave 3 compatibility export supports existing tests and callers.
_get_current_user = handlers._get_current_user
class _UserApiCompatModule(ModuleType):
"""Forward historic private test replacement points to the canonical handlers."""
def __setattr__(self, name: str, value: object) -> None:
super().__setattr__(name, value)
if hasattr(handlers, name):
setattr(handlers, name, value)
if hasattr(auth, name):
setattr(auth, name, value)
sys.modules[__name__].__class__ = _UserApiCompatModule
def __getattr__(name: str):
"""Expose historic test symbols from their formal auth or user module."""
if hasattr(auth, name):
return getattr(auth, name)
return getattr(handlers, name)
__all__ = ['auth_bp', 'user_bp']