【问题标题】:Why Persistent class is not working for ZODB为什么持久类不适用于 ZODB
【发布时间】:2018-12-23 13:25:50
【问题描述】:

我是 ZODB 和 Python 的新手。我从这个页面关注教程: http://www.zodb.org/en/latest/articles/ZODB1.html

在该页面的“持久类”部分下有一段代码:

import ZODB
from Persistence import Persistent

由于某种原因,它给了我错误:“ModuleNotFoundError: No module named 'Persistence'”

我错过了什么?创建和连接数据库工作正常。

【问题讨论】:

  • 本教程可能已过时。 IIRC,该模块现在命名为persistent,即使用from persistent import Persistent;以here为例
  • 感谢您的帮助。我想通了。
  • 该教程适用于 ZODB1;查看zodb.org/en/latest/tutorial.html,该模块现在称为persistence(小写)。

标签: python persistent zodb


【解决方案1】:

那篇文章现在已经相当老了,假设 ZODB 版本为 1.x;改为查看http://www.zodb.org/en/latest/tutorial.html,该模块现在称为persistence(小写):

from persistence import Persistence

更深入的信息,还有ZODB编程指南的Writing persistent objects section

【讨论】:

  • 感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-19
  • 1970-01-01
  • 1970-01-01
  • 2020-03-09
相关资源
最近更新 更多