refactor(backend): 重构后端代码 wave 3
This commit is contained in:
1 parent
affe139bf9
commit
8415653365
97 files changed
+4673
-6164
No files matched your search
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
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']
|
||||
Reference in new issue
Block a user