Commit 02a07723 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Revert "BusinessTemplate.py: PortalTypeWorkflowChainTemplateItem do not

fix the keys adding 'portal_type_workflow_chain/'
in _importFile, preinstall and export."

This reverts commit 6f8221b6.

This commit cleaned inconsistent prefix manipulation in
PortalTypeWorkflowChainTemplateItem. It passes the test suite,
however it was found to produce incompatibility with previously installed
business templates. In 'Upgrade Business Templates from Repositories"
there was a diff of PortalTypeWorkflowChainTemplateItems like:
Portal Type Name -> New
portal_type_workflow_chain/Portal Type Name -> Removed
For some reason the upgrade process would remove the chain
without adding the new element.

We are working on a clean solution, but since this needs more testing
I revert this commit for now so that master version does not cause
problems to users.
parent f235c6b0
...@@ -2520,6 +2520,16 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): ...@@ -2520,6 +2520,16 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
def export(self, context, bta, **kw): def export(self, context, bta, **kw):
if not self._objects: if not self._objects:
return return
# 'portal_type_workflow_chain/' is added in _importFile
# and if the template is not built,
# it should be removed here from the key
new_objects = PersistentMapping()
for key, value in self._objects.iteritems():
new_key = deepcopy(key)
if 'portal_type_workflow_chain/' in key:
new_key = new_key.replace('portal_type_workflow_chain/', '')
new_objects[new_key] = value
self._objects = new_objects
# export workflow chain # export workflow chain
xml_data = self.generateXml() xml_data = self.generateXml()
bta.addObject(xml_data, name='workflow_chain_type', bta.addObject(xml_data, name='workflow_chain_type',
...@@ -2629,7 +2639,9 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): ...@@ -2629,7 +2639,9 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
object_key_list = self._objects.keys() object_key_list = self._objects.keys()
for object_key in object_key_list: for object_key in object_key_list:
path_splitted = object_key.split('/', 1) path_splitted = object_key.split('/', 1)
portal_type = path_splitted[-1] if len(path_splitted) < 2:
continue
portal_type = path_splitted[1]
path = '%s%s' % (self._chain_string_prefix, portal_type) path = '%s%s' % (self._chain_string_prefix, portal_type)
if path in chain_dict: if path in chain_dict:
workflow_id_list = chain_dict[path].\ workflow_id_list = chain_dict[path].\
...@@ -2648,6 +2660,14 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): ...@@ -2648,6 +2660,14 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
def preinstall(self, context, installed_item, **kw): def preinstall(self, context, installed_item, **kw):
modified_object_list = {} modified_object_list = {}
new_dict = PersistentMapping()
# Fix key from installed bt if necessary
for key, value in installed_item._objects.iteritems():
if not 'portal_type_workflow_chain/' in key:
key = 'portal_type_workflow_chain/%s' % (key)
new_dict[key] = value
if new_dict:
installed_item._objects = new_dict
for path in self._objects: for path in self._objects:
if path in installed_item._objects: if path in installed_item._objects:
# compare object to see it there is changes # compare object to see it there is changes
...@@ -2680,6 +2700,9 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem): ...@@ -2680,6 +2700,9 @@ class PortalTypeWorkflowChainTemplateItem(BaseTemplateItem):
for chain in chain_list: for chain in chain_list:
portal_type = chain.find('type').text portal_type = chain.find('type').text
workflow_chain = chain.find('workflow').text or '' workflow_chain = chain.find('workflow').text or ''
if 'portal_type_workflow_chain/' not in portal_type:
key = 'portal_type_workflow_chain/%s' % (portal_type,)
else:
key = portal_type key = portal_type
result_dict[key] = workflow_chain.split(self._chain_string_separator) result_dict[key] = workflow_chain.split(self._chain_string_separator)
self._objects = result_dict self._objects = result_dict
......
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