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

发布于 2025-01-02 05:07:22 字数 489 浏览 0 评论 0原文

我有一个派生自 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 中找不到任何可用于此类情况的内容.文件夹和plone.文件夹。

I have a folder content type that derives from ATBTreeFolder which in plone 4(actually in Products.Archetypes) sets the ordering to "unordered".

If I go ahead and set the ordering to be ordered, which is just an empty string, the folder is confused and doesn't show me the contents of the folder. In fact, I'll get error like this:

  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.

I assume there is some migration that is required to be run to have ordering set on a folder that is originally unordered but I could not find anything available for that sort of situation in plone.app.folder and plone.folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一念一轮回 2025-01-09 05:07:22

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

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)

I have written an upgrade script that seems to solve the problem:

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文