Commit 7c19e3f3 authored by wenjie.zheng's avatar wenjie.zheng Committed by Sebastien Robin

ERP5Site.py: delicate way to migrate workflow tool without triggering security check.

parent 35962619
......@@ -45,6 +45,10 @@ import os
import warnings
import transaction
from App.config import getConfiguration
from Products.ERP5.Tool.ERP5WorkflowTool import ERP5WorkflowTool
from zope.lifecycleevent import ObjectCopiedEvent
from OFS.event import ObjectClonedEvent
from zope.event import notify
MARKER = []
# Site Creation DTML
......@@ -1644,15 +1648,31 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
"""
tool = self.portal_workflow
if tool.getPortalType() != 'ERP5 Workflow Tool':
object_id_list = tool.objectIds()
object_clipboard = tool.manage_copyObjects(object_id_list)
new_tool = self.newContent(id='portal_workflow_new', portal_type='ERP5 Workflow Tool')
new_tool.manage_pasteObjects(object_clipboard)
# create new ERP5 Workflow Tool
self._setObject('portal_workflow_new', ERP5WorkflowTool())
new_tool = getattr(self, 'portal_workflow_new')
new_tool._chains_by_type = tool._chains_by_type
# backup old type workflow tool
self.manage_delObjects('portal_workflow')
self.manage_renameObject(new_tool.id, 'portal_workflow')
new_tool.id = 'portal_workflow'
# copy-paste operation
for id in tool.objectIds():
ob = tool._getOb(id)
orig_id = ob.getId()
ob._notifyOfCopyTo(new_tool, op=0)
orig_ob = ob
ob = ob._getCopy(new_tool)
ob._setId(id)
notify(ObjectCopiedEvent(ob, orig_ob))
new_tool._setObject(id, ob)
ob = new_tool._getOb(id)
ob.wl_clearLocks()
ob._postCopy(new_tool, op=0)
notify(ObjectClonedEvent(ob))
# migration
self.portal_workflow = new_tool
self.portal_workflow.id = 'portal_workflow'
self._delObject(new_tool)
Globals.InitializeClass(ERP5Site)
def getBootstrapDirectory():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment