Automation tool for Plone edition

你。 提交于 2020-01-15 14:27:24

问题


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.

Did the following:

  1. I saved all the pages that needed correction to a folder (by copy & paste);
  2. wrote a C program to find all occurrences of URLs to be replaced;
  3. placed in a text file the old URLs and their substitutes URLs (one line below another: old URL, new URL, the old URL, new URL, the old URL, ...);
  4. then another program made the appropriate substitutions.
  5. after that, just reset the pages (copy & paste). It happens that spent a lot of time in steps 1 and 5. I wonder if there was any way to automate this procedure? In other words: is there any Plone tool that automatically save all pages of a portal in a computer folder and then do the opposite (from the computer to the server)? I have searched a lot and did not find.

回答1:


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.

More info: https://pypi.python.org/pypi/plone.app.redirector/




回答2:


If new there some kind of relations between the format of old URL's to new ones, using rt.bulkmodify may help a lot.




回答3:


All automated solutions need an administrator, since they involve installing add-ons.

Having that as a pre-requisite, if you for some reason need to programatically change these links without creating a full blown package to do it (or if the suggestions gave here won't solve your specific problem), you could interact with your ZODB in command line with a simple Python script that would do it for you.

Always backup your ZODB before doing these operations.



来源:https://stackoverflow.com/questions/28521918/automation-tool-for-plone-edition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!