Julien Anguenot wrote:
Salut Jean-Marc,
Jean-Marc Orliaguet wrote:
I'm about to migrate a couple of documents from "documentish" to
folderish (FolderishProxyDocument)
CPS uses isinstance(ProxyFolderishDocument) in some places, so changing
to portal type to folderish is not enough.
instances must be changed too.
the current script does:
for brain in brains:
ob = brain.getObject()
if ob is None:
continue
if isinstance(ob, ProxyFolderishDocument):
continue
ob.__class__ = ProxyFolderishDocument
ob._p_changed = 1 # trigger persistence
ob.proxyChanged()
# + some workflow history stuff omitted here
anything more to think about ?
You may need to update the workflow related annotations on the object as
well and ensure it's compatible with the folferish workflow your objects
are gonna follow after this migration. I guess you will need to update
your workflow associations as well to specify a folderish workflow
instead of the former one.
Keep us posted about the result.
J.
Yes, I did that too. The tricky issue was the __class__ change, it
didn't get persisted correctly in the beginning.
here is the entire script ...
cross-fingers ;-)
/JM
from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
from Products.CPSCore.ProxyBase import ProxyFolderishDocument
def upgrade_personal_pages(self):
ctool = getToolByName(self, 'portal_catalog')
nchanged = 0
brains = ctool.searchResults(portal_type=('Chalmers personal page',))
for brain in brains:
ob = brain.getObject()
if ob is None:
continue
if isinstance(ob, ProxyFolderishDocument):
continue
ob.__class__ = ProxyFolderishDocument
workflow_history = getattr(aq_base(ob), 'workflow_history', None)
if workflow_history is None:
continue
changed = 0
for wf_id, wfh in workflow_history.items():
if wf_id != 'workspace_content_wf':
continue
new_wfh = ()
for wf in wfh:
new_wf = {}
for k, v in wf.items():
if k == 'workflow_id':
if v == 'workspace_content_wf':
v = 'workspace_folderish_content_wf'
new_wf[k] = v
new_wfh += new_wf,
workflow_history['workspace_folderish_content_wf'] = new_wfh
workflow_history._p_changed = 1 # trigger persistence
changed = 1
if changed:
path = '/'.join(ob.getPhysicalPath())
nchanged += 1
return '%s personal pages migrated to folderish documents' % nchanged
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel