Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top