Changing workflow in multilingual site works only for one language

為{幸葍}努か 提交于 2019-12-11 12:09:21

问题


I have a fresh Plone-4.1.5-site with Linguaplone-4.1.1 installed, two languages selected and the front-page translated into the other language.

When changing the workflow from simple_workflow to intranet_workflow via the controlpanel, and mapping old states to new ones, it occurs, that only objects of the current chosen language get the new mapping. Objects of the other language get the initial state of the new workflow.

Is it possible to do the mapping programatically to overcome this?


回答1:


In this case, it'll probably be simplest to just patch the code that remaps the workflows.

Open the plone.app.workflow egg (it's path will be listed in your bin/instance script), find the plone/app/workflow/remap.py file and edit it.

About halfway down you'll find the following line (line 79 in my copy):

for brain in portal_catalog(portal_type=type_ids):

and add Language='all' to that:

for brain in portal_catalog(portal_type=type_ids, Language='all'):

The alternative is copying that whole file into your own project, make that change locally, then calling it with:

statemap = {
    'oldstate1_id': 'newstate1_id',
    'oldstate2_id': 'newstate2_id'
}
chain_name = ('workflow_id',)  # tuple of wf ids (can be empty), or the string '(Default)'
portal_types = ('sequence', 'of', 'portal_types')

copiedremap.remap_workflow(portal, portal_types, chain_name, state_map)

The remap_workflow script then uses the current state of the object to find the new state it should have in the new target workflow(s) (it'll do this for each new workflow); if the old state is not listed in the map it'll use the initial state of the target workflow.



来源:https://stackoverflow.com/questions/13901739/changing-workflow-in-multilingual-site-works-only-for-one-language

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