__init__.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. # @Author : YY
  3. import os
  4. import sys
  5. from types import ModuleType
  6. from werkzeug.exceptions import HTTPException
  7. from ruoyi_common.base.serializer import JsonProvider,handle_http_exception,handle_util_exception
  8. from ruoyi_common.descriptor.listener import ModuleSignalListener
  9. from ruoyi_common.base.signal import module_initailize
  10. from ruoyi_common.ruoyi.registry import RuoYiModuleRegistry
  11. from ruoyi_common.utils.base import UtilException
  12. @ModuleSignalListener(sys.modules[__name__],module_initailize)
  13. def import_hook(module:ModuleType, registry:RuoYiModuleRegistry):
  14. """
  15. 导入模块
  16. 初始化app的一些操作:
  17. 1.注册json序列化器
  18. 2.注册错误处理器
  19. Args:
  20. module: 模块对象
  21. module_register: 模块注册器
  22. """
  23. os.environ['WERKZEUG_DEBUG_PIN'] = 'off'
  24. registry.app.json_provider_class = JsonProvider
  25. registry.app.register_error_handler(
  26. HTTPException, handle_http_exception
  27. )
  28. registry.app.register_error_handler(
  29. UtilException, handle_util_exception
  30. )