portal/app/portal.py

59 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Portal Web应用主入口 — CMS业务壳
启动: py3/bin/python app/portal.py -p 9090 -w $(pwd)
Portal是一个轻量级Web应用壳通过pip install加载cms业务模块。
类似pipeline-app模式app壳负责基础设施初始化业务逻辑在模块中。
"""
import os, sys
# 添加应用根目录到Python路径
app_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(app_dir)
sys.path.insert(0, root_dir)
# Ensure app/ is in path for local imports
sys.path.insert(0, app_dir)
from appPublic.log import MyLogger, info
from appPublic.folderUtils import ProgramPath
from appPublic.jsonConfig import getConfig
from appPublic.registerfunction import RegisterFunction
from bricks_for_python.init import load_pybricks
from ahserver.webapp import webapp
from ahserver.serverenv import ServerEnv
from sqlor.dbpools import DBPools
# CMS业务模块 (通过pip install -e ~/repos/cms安装)
from cms.init import load_cms
# RBAC认证(复用sage的rbac模块)
from rbac.init import load_rbac
from appbase.init import load_appbase
# 全局函数
from global_func import set_globalvariable
__version__ = '1.0.0'
def get_module_dbname(m):
return 'ocai_cms'
def init():
rf = RegisterFunction()
set_globalvariable()
env = ServerEnv()
env.get_module_dbname = get_module_dbname
# Initialize DBPools and register db on ServerEnv for dspy use
config = getConfig('.')
env.db = DBPools(config.databases)
load_pybricks()
load_appbase()
load_rbac()
load_cms()
if __name__ == '__main__':
webapp(init)