【问题标题】:How to search and replace dexterity content in Plone using rt.bulkmodify如何使用 rt.bulkmodify 在 Plone 中搜索和替换敏捷内容
【发布时间】:2015-02-18 18:44:27
【问题描述】:

我们正在从旧的现有静态站点迁移到 Plone 4.3。我们已经从旧站点导入了几个 HTML 页面,现在面临 8000 多个硬编码链接,这些链接需要在我们的 Plone 系统中更新以匹配我们的新 url 标准。这些页面是使用自定义灵巧类型构建的。我们不想手动编辑这些。

我们想在 Plone 中使用批量修改工具。我们正在尝试使用它来使用正则表达式替换我们所有的链接。不幸的是,无论我们使用这个工具在 Plone 中搜索什么,它都找不到一个结果。

我觉得我们错过了一个步骤,或者我们走错了路。

是否有我们遗漏的程序,或者是否有更好的方法来搜索和替换我们灵巧类型内容中的硬编码链接?我们认为我们可能需要以某种方式索引灵巧性内容,以便它可以被搜索。

如果这是真的,我们似乎找不到这方面的文档。

以下是我们用来尝试使其正常工作的参考资料:

Plone.org - rt.bulkmodify

Python - rt.bulkmodify

Plone.org - catalog-indexing-strategies

【问题讨论】:

  • 我们正在研究索引敏捷内容类型。我们的结果中从未出现过的一个问题可能会帮助我们找到解决方案。 stackoverflow.com/questions/8852132/…
  • 有一个类似的问题here。检查它是否对您有帮助。 ;)
  • 只是检查:您是否将您的 Dexterity 内容类型添加为新的处理程序,如 pypi.python.org/pypi/rt.bulkmodify/… 中所述?在 rt.bulkmodify 对您的内容类型起作用之前,这是绝对需要的。
  • @tcuvelo 谢谢!我们将看看这个。
  • @polyester 我将不得不检查我们的 Plone 管理员。他是设置这一切的人。从我选择的答案来看,它看起来不像我们可以继续我们想要的方式。感谢您的帮助!

标签: python regex replace plone zope


【解决方案1】:

抱歉,rt.bulkmodify 目前不支持敏捷。您必须提供适当的IBulkModifyContentChanger 适配器。

这里是我们正在为 plone.app.contenttypes/Plone 5 兼容性开发的未发布版本(由于目前无法在 Plone 5 上真正运行,因此未进行真正测试)。也应该适用于 Plone 4 上的纯灵巧自定义类型:

from ..interfaces import IBulkModifyContentChanger
from zope.interface import implements


class TextContentAdapters(object):
    """This is OK for every know plone.app.contenttypes dexterity item"""

    implements(IBulkModifyContentChanger)

    def __init__(self, context):
        self.context = context

    def _get_text(self):
        return self._get_utext().encode('utf-8')

    def _set_text(self, text):
        raise NotImplementedError("%s doesn't implements setter for 8-bit string" % self.context.portal_type)

    def _get_utext(self):
        text_data = getattr(self.context, 'text', None)
        if text_data:
            return text_data.raw

    def _set_utext(self, text):
        self.context.text = text
        self.context.reindexObject(idxs=['SearchableText'])

    text = property(_get_text, _set_text)
    utext = property(_get_utext, _set_utext)

【讨论】:

  • 谢谢!我们将尝试使其发挥作用。知道目前不支持它使我们能够继续我们拥有的其他想法。我们将尝试这种方法,看看它是否对我们有帮助。
猜你喜欢
  • 1970-01-01
  • 2015-11-23
  • 1970-01-01
  • 1970-01-01
  • 2012-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-29
相关资源
最近更新 更多