- app/portal.py: 主入口,通过from cms.init import load_cms加载业务模块 - conf/config.json: 应用配置(ocai_cms数据库, 端口9090, cms模块wwwroot挂载到/cms) - wwwroot/: 公开页面(index/news/cases/products)和公开API - build.sh: 构建脚本(安装基础设施包+pip install cms模块+DDL/CRUD生成) - deploy.sh: 一键部署脚本(构建→建表→初始数据→权限→启动) - init_data.py: 从cms模块init/data.yaml加载初始数据 - init_any/superuser_permissions.py: RBAC权限初始化
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
"""
|
||
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
|
||
load_pybricks()
|
||
load_appbase()
|
||
load_rbac()
|
||
load_cms()
|
||
|
||
if __name__ == '__main__':
|
||
webapp(init)
|