Plone 版的自动化工具 [英] Automation tool for Plone edition

查看:52
本文介绍了Plone 版的自动化工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编辑器配置文件中注册了一个用 Plone 编写的门户.我接到了将多个链接(超过 1000 个)更改为新地址的任务.

I am registered to the editor profile a portal written in Plone. I received the task of changing multiple links (over 1000) to their new addresses.

做了以下事情:

  1. 我将所有需要更正的页面保存到一个文件夹中(通过复制和粘贴);
  2. 编写了一个 C 程序来查找所有要替换的 URL;
  3. 将旧网址及其替代网址放在文本文件中(在另一行下方:旧网址、新网址、旧网址、新网址、旧网址等);
  4. 然后另一个程序进行了适当的替换.
  5. 之后,只需重置页面(复制和粘贴).碰巧在第 1 步和第 5 步中花费了大量时间.我想知道是否有任何方法可以使此过程自动化?换句话说:是否有任何 Plone 工具可以自动将门户的所有页面保存在计算机文件夹中,然后执行相反的操作(从计算机到服务器)?我搜索了很多,没有找到.

推荐答案

如果这些链接指向同一站点中的旧位置,您只需使用 plone.app.redirector 将它们重定向到新地点:

If these links point to old locations in the same site, you could just use plone.app.redirector to redirect them to the new locations:

from plone.app.redirector.interfaces import IRedirectionStorage
from zope.component import getUtility

storage = getUtility(IRedirectionStorage)
paths = [('old/path/1', 'new/path/1'), ('old/path/2', 'new/path/2'), ]

for old_path, new_path in paths:
    storage.add(old_path, new_path)

这样,您就不必编辑包含旧链接的每个页面.

This way, you don't have to edit every single page that contains a old link.

更多信息:https://pypi.python.org/pypi/plone.app.redirector/

这篇关于Plone 版的自动化工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆