dspy文件修复(27个entcms + 10个dingdingflow): - 删除所有import语句(dspy环境已预加载) - 替换 sor = DBPools().sqlorContext() 为 async with db.sqlorContext() as sor: - 替换 print(json.dumps()) 为 return - 替换 uuid() 为 getID() - 替换 datetime.datetime.now() 为 datetime.now() - 修复 get_user() 缺少 await - 删除shebang/docstrings等无关内容 - 修正缩进 Python模块修复: - entcms/init.py: DBNAME从'entcms'改为'ocai_cms' - app/global_func.py: get_module_dbname返回'ocai_cms'而非'sage' - 所有函数使用 async with db.sqlorContext() as sor: 正确模式
57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
"""
|
|
CMS全局函数 — 注册到ServerEnv供.dspy和.ui调用
|
|
"""
|
|
from ahserver.serverenv import ServerEnv
|
|
|
|
def get_module_dbname(mname):
|
|
"""CMS应用统一使用ocai_cms数据库"""
|
|
return 'ocai_cms'
|
|
|
|
def UiWindow(title, icon, content, cheight=10, cwidth=15):
|
|
return {
|
|
"widgettype": "PopupWindow",
|
|
"options": {
|
|
"author": "cms",
|
|
"cwidth": cwidth,
|
|
"cheight": cheight,
|
|
"title": title,
|
|
"content": content,
|
|
"icon": icon or entire_url('/bricks/imgs/app.png'),
|
|
"movable": True,
|
|
"auto_open": True
|
|
}
|
|
}
|
|
|
|
def UiError(title="出错", message="出错啦", timeout=5):
|
|
return {
|
|
"widgettype": "Error",
|
|
"options": {
|
|
"author": "cms",
|
|
"timeout": timeout,
|
|
"cwidth": 15,
|
|
"cheight": 10,
|
|
"title": title,
|
|
"message": message
|
|
}
|
|
}
|
|
|
|
def UiMessage(title="消息", message="后台消息", timeout=5):
|
|
return {
|
|
"widgettype": "Message",
|
|
"options": {
|
|
"author": "cms",
|
|
"timeout": timeout,
|
|
"cwidth": 15,
|
|
"cheight": 10,
|
|
"title": title,
|
|
"message": message
|
|
}
|
|
}
|
|
|
|
def set_globalvariable():
|
|
g = ServerEnv()
|
|
g.get_module_dbname = get_module_dbname
|
|
g.UiError = UiError
|
|
g.UiMessage = UiMessage
|
|
g.UiWindow = UiWindow
|