我们希望在一个脚本操作中将对象移动并重命名到Plone中的不同文件夹。
发布于 2012-07-22 10:08:23
你应该剪切+粘贴+ manage_renameObjects()。这是您唯一可用的API。:-)
我经常为这项工作使用助手方法:
from Acquisition import aq_parent, aq_inner
def move(id_=None, ob=None, parent=None, dest=None, newid=None):
# Either provide id and parent, or ob.
if id_ is None:
id_ = ob.getId()
if parent is None:
parent = aq_parent(aq_inner(ob))
clipboard = parent.manage_cutObjects([id_])
result = dest.manage_pasteObjects(clipboard)
if newid is not None:
dest.manage_renameObject(result['new_id'], newid)发布于 2015-02-24 10:54:36
Martijns当时的回答是正确的,但现在Plone有了一个API,它提供了所需的方法:
http://docs.plone.org/external/plone.api/docs/content.html#move-content
https://stackoverflow.com/questions/11574507
复制相似问题