python - 如何将无序文件夹迁移到 Plone 中的有序文件夹

标签 python plone zope archetypes

我有一个派生自 ATBTreeFolder 的文件夹内容类型,它在 plone 4 中(实际上在 Products.Archetypes 中)将排序设置为“无序”。

如果我继续设置要排序的顺序(这只是一个空字符串),则该文件夹会很困惑并且不会显示该文件夹的内容。事实上,我会得到这样的错误:

  File "buildout-cache/eggs/plone.folder-1.0.1-py2.6.egg/plone/folder/default.py", line 130, in getObjectPosition
    raise ValueError('No object with id "%s" exists.' % id)
ValueError: No object with id "someid" exists.

我假设需要运行一些迁移才能在最初无序的文件夹上设置排序,但我在 plone.app.folder 和 plone.folder 中找不到适用于这种情况的任何内容。

最佳答案

我写了一个升级脚本,似乎可以解决这个问题:

catalog = getToolByName(context, 'portal_catalog')
for brain in catalog(portal_type='MyType'):
    obj = brain.getObject()
    if obj._ordering == 'unordered':
        obj.setOrdering(u'')
    order = obj.getOrdering()
    for id in obj._tree:
        if id not in order._order():
            order.notifyAdded(id)

关于python - 如何将无序文件夹迁移到 Plone 中的有序文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9131574/

相关文章:

plone - 搜索多个 Plone 站点索引

plone - 尝试安装 ZRS 时 DistributionNotFound

plone - 敏捷中的多值属性

plone - 如何在 Plone 4 中将抄送收件人添加到电子邮件中?

plone - 您没有在 Plone 的 [genericsetupprofile registration] 中为 ... 指定 i18n 翻译域

python - split :zope.testbrowser 的 DriverNotFoundError

python - Dask 的多处理中方法被调用两次而不是一次调用

python - 如何在没有表单的情况下直接在django中将项目添加到数据库

python - 非贪婪组之后的可选组

python - 如何在 py.test 中加载自定义插件