[Erp5-report] r16268 - /erp5/trunk/products/ERP5/Document/BusinessTemplate.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Sep 11 16:58:48 CEST 2007
Author: romain
Date: Tue Sep 11 16:58:48 2007
New Revision: 16268
URL: http://svn.erp5.org?rev=16268&view=rev
Log:
Recreate right path when comparing object thus avoiding having
remove/install of Document, PropertySheet, Constraint.
Fix reinstall method, in order not to change the BusinessTemplate state to
replaced.
Modified:
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=16268&r1=16267&r2=16268&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py Tue Sep 11 16:58:48 2007
@@ -699,7 +699,11 @@
groups[path] = deepcopy(obj.groups)
# copy the object
obj = obj._getCopy(container)
- container._setObject(object_id, obj)
+ try:
+ container._setObject(object_id, obj)
+ except AttributeError:
+ LOG("BT, install", 0, object_id)
+ raise
obj = container._getOb(object_id)
# mark a business template installation so in 'PortalType_afterClone' scripts
# we can implement logical for reseting or not attributes (i.e reference).
@@ -1637,7 +1641,7 @@
# fix key if necessary in installed bt for diff
for key in installed_bt._objects.keys():
if self.class_property not in key:
- new_key = self.class_property+'/'+key
+ new_key = '%s/%s' % (self.class_property, key)
new_dict[new_key] = installed_bt._objects[key]
else:
new_dict[key] = installed_bt._objects[key]
@@ -2611,20 +2615,33 @@
modified_object_list = {}
if context.getTemplateFormatVersion() == 1:
new_keys = self._objects.keys()
+ new_dict = PersistentMapping()
+ # fix key if necessary in installed bt for diff
+ for key in installed_bt._objects.keys():
+ if self.__class__.__name__ in key:
+ new_key = key[len('%s/' % self.__class__.__name__):]
+ new_dict[new_key] = installed_bt._objects[key]
+ else:
+ new_dict[key] = installed_bt._objects[key]
+ if len(new_dict):
+ installed_bt._objects = new_dict
for path in new_keys:
if installed_bt._objects.has_key(path):
# compare object to see if there is changes
new_obj_code = self._objects[path]
old_obj_code = installed_bt._objects[path]
if new_obj_code != old_obj_code:
- modified_object_list.update({path : ['Modified', self.__class__.__name__[:-12]]})
+ modified_object_list.update(
+ {path : ['Modified', self.__class__.__name__[:-12]]})
else: # new object
- modified_object_list.update({path : ['New', self.__class__.__name__[:-12]]})
+ modified_object_list.update(
+ {path : ['New', self.__class__.__name__[:-12]]})
# get removed object
old_keys = installed_bt._objects.keys()
for path in old_keys:
if path not in new_keys:
- modified_object_list.update({path : ['Removed', self.__class__.__name__[:-12]]})
+ modified_object_list.update(
+ {path : ['Removed', self.__class__.__name__[:-12]]})
return modified_object_list
def install(self, context, trashbin, **kw):
@@ -4157,7 +4174,8 @@
installed_bt = self.portal_templates.getInstalledBusinessTemplate(
self.getTitle())
- if installed_bt is not None:
+ # When reinstalling, installation state should not change to replaced
+ if installed_bt not in [None, self]:
if installed_bt.getTemplateFormatVersion() == 0:
force = 1
installed_bt.replace(self)
More information about the Erp5-report
mailing list