Added/updated 页面在使用 postgres 的 Django CMS 3.0 (mptt) 文章树中的错误位置

Added/updated pages in wrong place in Django CMS 3.0 (mptt) article tree using postgres

对于 https://developer.ubuntu.com,我们使用 Django CMS 3.0.6 (mptt),我们对此非常满意。

最近我们添加了从项目的 bzr 分支导入 markdown 文档的功能,这样我们就可以在我们感兴趣的一些上游项目发生变化时让 cronjobs 为我们更新文章。这花了我一些时间完成它,但我们得到它的工作。在本地,我使用了 sqlite(默认)并且很高兴。一旦部署到暂存区,导入也能正常工作,但脚本添加或更新的文章最终会出现在文章树中的不同位置。一段时间后,我可以使用本地 postgres 安装重现它。

我们目前正在跟踪这里的问题:https://bugs.launchpad.net/developer-ubuntu-com/+bug/1506861

我有点迷茫,不太知道如何调试它。

我为此整理了一个测试用例,基本上是:

$ bzr branch lp:~developer-ubuntu-com-dev/developer-ubuntu-com/debug-md-importer
$ cd debug-md-importer
$ virtualenv ./env
$ ./env/bin/pip install -r requirements.txt
$ ./env/bin/pip install django psycopg2

然后将 http://pastebin.ubuntu.com/12798510/ 之类的差异应用到 developer_portal/settings.py 和 运行

$ sudo apt install python-pip python-dev libpq-dev postgresql postgresql-contrib
$ sudo -u postgres psql -c "CREATE USER developerportal_user WITH PASSWORD '123abc';"

要查看实际问题,请 运行:

$ ./postgres-retry.sh

在 postgres 设置中并且

$ ./sqlite-retry.sh

在 sqlite 设置中。

脚本将从头开始创建一个新的数据库,运行 带有调试消息的导入器和 运行 运行 服务器为您创建,因此您可以轻松地检查页面列表如何结构改变了。

目前的情况: sqlite 很好,而 postgres 的文章树搞砸了。

这个问题的所有相关代码都可以在developer_portal/management/commands/import-external-docs-branches.py

中找到

如果有人能给我指点,将不胜感激。

非常感谢。

祝你有美好的一天, 丹尼尔

我从 http://bazaar.launchpad.net/~developer-ubuntu-com-dev/developer-ubuntu-com/debug-md-importer/view/head:/requirements.txt#L18 看到您使用的是 django CMS 3.0.6,这意味着您正在使用 Django MPTT。

一般来说,人们在使用 django CMS 时遇到的大多数树问题都被证明是移动后的损坏,与 Django MPTT 有关。

如果您还没有这样做,您可以尝试以下操作之一:

  • 而不是使用 django-mptt==0.6.1 尝试最新版本的 https://github.com/django-mptt/django-mptt
  • 我还没有机会 运行 通过你的流程,但如果可能的话,请尝试 运行在每次操作后执行 manage.py cms fix-mptt 命令
  • 在 django CMS 3.1 中,我们开始使用 Treebeard 而不是 MPTT。如果您能够尝试使用 3.1 而不是 3.0.x 而无需太多额外的工作,那可能是一个有用的实验。