Commit ae10692a authored by Łukasz Nowak's avatar Łukasz Nowak

- fix removal of virutal paths done in http://svn.erp5.org/?view=revision&revision=33779

As it is possible to have non unique paths from Business Template point of view
(like having same file name for Test and Document) it is required to have "magically"
generated unique paths.

As Business Template internal data migration is unwanted, BusinessTemplate._objects
are not modified. So, while installing new Business Template, no magic is applied, but
becuase of different way of doing fresh installation and upgrade during fresh
installation problems of conflicting paths does not appear.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45296 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 38aab762
......@@ -3337,6 +3337,16 @@ class DocumentTemplateItem(BaseTemplateItem):
local_file_importer_name = staticmethod(importLocalDocument)
local_file_remover_name = staticmethod(removeLocalDocument)
def _getKey(self, path):
"""Magical method to generate dynamic unique path"""
return '/'.join((self.getTemplateTypeName(), path))
def _getPath(self, key):
"""Magical method to extract real path"""
if '/' in key:
return key.split('/')[1]
return key
def build(self, context, **kw):
BaseTemplateItem.build(self, context, **kw)
for key in self._archive.iterkeys():
......@@ -3359,17 +3369,20 @@ class DocumentTemplateItem(BaseTemplateItem):
new_obj_code = self._objects[path]
old_obj_code = installed_item._objects[path]
if new_obj_code != old_obj_code:
# Note: Magical way to have unique paths
modified_object_list.update(
{path : ['Modified', self.__class__.__name__[:-12]]})
{self._getKey(path) : ['Modified', self.__class__.__name__[:-12]]})
else: # new object
# Note: Magical way to have unique paths
modified_object_list.update(
{path : ['New', self.__class__.__name__[:-12]]})
{self._getKey(path) : ['New', self.__class__.__name__[:-12]]})
# get removed object
old_keys = installed_item._objects.keys()
for path in old_keys:
if path not in new_keys:
# Note: Magical way to have unique paths
modified_object_list.update(
{path : ['Removed', self.__class__.__name__[:-12]]})
{self._getKey(path) : ['Removed', self.__class__.__name__[:-12]]})
return modified_object_list
def _resetDynamicModules(self):
......@@ -3423,6 +3436,16 @@ class DocumentTemplateItem(BaseTemplateItem):
if self.local_file_importer_name is not None:
self.local_file_importer_name(id)
def remove(self, context, **kw):
"""Conversion of magically uniqued paths to real ones"""
remove_object_dict = kw.get('remove_object_dict', {})
new_remove_dict = dict()
for k,v in remove_object_dict.iteritems():
if k.startswith(self.getTemplateTypeName()+'/'):
new_remove_dict[self._getPath(k)] = v
kw['remove_object_dict'] = new_remove_dict
BaseTemplateItem.remove(self, context, **kw)
def uninstall(self, context, **kw):
object_path = kw.get('object_path', None)
if object_path is not None:
......@@ -3667,6 +3690,27 @@ class PropertySheetTemplateItem(DocumentTemplateItem,
# migrated
update_parameter_dict[key] = 'migrate'
def remove(self, context, **kw):
"""Conversion of magically uniqued paths to real ones"""
remove_object_dict = kw.get('remove_object_dict', {})
new_remove_dict = dict()
for k,v in remove_object_dict.iteritems():
if k.startswith(self.getTemplateTypeName()+'/'):
new_remove_dict[self._getPath(k)] = v
kw['remove_object_dict'] = new_remove_dict
ObjectTemplateItem.remove(self, context, **kw)
def preinstall(self, *args, **kwargs):
preinstall_dict = ObjectTemplateItem.preinstall(self, *args, **kwargs)
new_preinstall_dict = dict()
for k, v in preinstall_dict.iteritems():
if not k.startswith('portal_property_sheets/'):
# Magical way to have unique path in case of not yet migrated property
# sheets available on preinstall list
k = self._getKey(k)
new_preinstall_dict[k] = v
return new_preinstall_dict
def install(self, context, **kw):
if not self._perform_migration:
return DocumentTemplateItem.install(self, context, **kw)
......
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