fix: deploy fixes - db on ServerEnv, bricks symlink, dspy entcms->cms, config paths, init_data

This commit is contained in:
Hermes Agent 2026-06-15 11:54:47 +08:00
parent ae06dda9da
commit 7f5f5ac10d
9 changed files with 16 additions and 13 deletions

View File

@ -2,6 +2,7 @@
Portal全局函数 注册到ServerEnv供.dspy和.ui调用
"""
from ahserver.serverenv import ServerEnv
from appPublic.jsonConfig import getConfig
def get_module_dbname(mname):
"""Portal应用统一使用ocai_cms数据库"""
@ -50,6 +51,7 @@ def UiMessage(title="消息", message="后台消息", timeout=5):
def set_globalvariable():
g = ServerEnv()
g.getConfig = getConfig
g.get_module_dbname = get_module_dbname
g.UiError = UiError
g.UiMessage = UiMessage

View File

@ -44,6 +44,11 @@ def init():
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()

View File

@ -1,5 +1,5 @@
{
"password_key":"!@#$%^&*(*&^%$QWERTYUIqwertyui234567",
"password_key": "!@#$%^&*(*&^%$QWERTYUIqwertyui234567",
"logger": {
"name": "portal",
"levelname": "info",
@ -29,10 +29,6 @@
[
"$[workdir]$/../cms/wwwroot",
"/cms"
],
[
"$[workdir]$/bricks",
"/bricks"
]
],
"host": "0.0.0.0",
@ -77,4 +73,4 @@
"zh-Hans-CN": "zh-cn",
"en-US": "en"
}
}
}

View File

@ -23,7 +23,7 @@ except ImportError:
# 简单YAML解析(fallback)
yaml = None
CMS_DIR = os.path.expanduser("~/repos/cms")
CMS_DIR = os.path.expanduser("~/cms")
DATA_FILE = os.path.join(CMS_DIR, "init", "data.yaml")
def load_yaml_simple(path):
@ -62,7 +62,7 @@ def main():
# 初始化日志和配置
MyLogger(getConfig())
db = DBPools()
db = DBPools(getConfig().databases)
dbname = 'ocai_cms'
import asyncio

View File

@ -1,7 +1,7 @@
config = getConfig('.')
DBPools(config.databases)
dbname = get_module_dbname('entcms')
dbname = get_module_dbname('cms')
async with db.sqlorContext(dbname) as sor:
group = params_kw.get('group', None)

View File

@ -1,7 +1,7 @@
config = getConfig('.')
DBPools(config.databases)
dbname = get_module_dbname('entcms')
dbname = get_module_dbname('cms')
async with db.sqlorContext(dbname) as sor:
_id = params_kw.get('id', '')

View File

@ -1,7 +1,7 @@
config = getConfig('.')
DBPools(config.databases)
dbname = get_module_dbname('entcms')
dbname = get_module_dbname('cms')
async with db.sqlorContext(dbname) as sor:
content_type = params_kw.get('content_type', None)

View File

@ -1,7 +1,7 @@
config = getConfig('.')
DBPools(config.databases)
dbname = get_module_dbname('entcms')
dbname = get_module_dbname('cms')
async with db.sqlorContext(dbname) as sor:
ns = {'is_visible': '1', 'sort': 'sort_order asc'}

View File

@ -1,6 +1,6 @@
config = getConfig('.')
DBPools(config.databases)
dbname = get_module_dbname('entcms')
dbname = get_module_dbname('cms')
async with db.sqlorContext(dbname) as sor:
data = {