相关疑难解决方法(0)

更新 Pyramid 应用程序时 SQLAlchemy 出现的 ZopeTransactionEvents 错误是什么?

我正在将 Pyramid/SQLAlchemy 遗留代码从在 Python 2.7 下正常工作的应用程序更新到 Python 3.8,并在本地运行它。所有必要的要求都已安装,并且 setup.py 运行没有错误。

initialise使用本地 .ini 文件运行时,一切顺利,数据库表 (MariaDB) 均已写入。

在 models.py 中

from sqlalchemy.orm import (
    scoped_session,
    sessionmaker,
    relationship,
    backref,
    synonym,
    )
from zope.sqlalchemy import ZopeTransactionEvents
#[...]
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionEvents()))
Run Code Online (Sandbox Code Playgroud)

'ZopeTransactionEvents' object has no attribute 'after_commit'在主应用程序中,在获得最终输入并尝试将其添加到数据库后,此函数失败DBSession.add(user)

def do_create_admin_user(self):
    from ..models import User
    from getpass import getpass
    print("Create an administrative user")
    fullname = input("full name: ")
    username = input("username: ")
    if not username:
        self.log.info("missing username - aborted")
        return
    if len(username) …
Run Code Online (Sandbox Code Playgroud)

python pylons sqlalchemy python-3.x pyramid

1
推荐指数
1
解决办法
460
查看次数

标签 统计

pylons ×1

pyramid ×1

python ×1

python-3.x ×1

sqlalchemy ×1