Commit 42422b43 authored by Romain Courteaud's avatar Romain Courteaud

Fix the diff method, but not yet usable enough.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4308 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 228dfaa2
......@@ -334,6 +334,9 @@ class ObjectTemplateItem(BaseTemplateItem):
object.wl_clearLocks()
def _backupObject(self, container, object_id, **kw):
"""
Rename object as a _btsave_
"""
container_ids = container.objectIds()
n = 0
new_object_id = object_id
......@@ -451,11 +454,11 @@ class ObjectTemplateItem(BaseTemplateItem):
diff_list = list(diff_instance.compare(xml_dict[str(object1)],
xml_dict[str(object2)]))
diff_list = [x for x in diff_list if x[0] != ' ']
# Dirty patch to remove useless diff message (id different)
if btsave_object_included==1:
if len(diff_list) == 3:
if '_btsave_' in diff_list[1]:
diff_list = []
# # Dirty patch to remove useless diff message (id different)
# if btsave_object_included==1:
# if len(diff_list) == 3:
# if '_btsave_' in diff_list[1]:
# diff_list = []
# Return string
result = '%s' % ''.join(diff_list)
return result
......@@ -467,8 +470,25 @@ class ObjectTemplateItem(BaseTemplateItem):
"""
result = ''
portal = self.getPortalObject()
if (getattr(self, 'template_format_version', 0)) == 0:
object_list = getattr(self, archive_variable).items()
else:
try:
object_list = []
keys = self._objects.keys()
keys.sort()
for path in keys:
container_path = path.split('/')[2:-1]
object_id = path.split('/')[-1]
container = portal.unrestrictedTraverse(container_path)
object = self._objects[path]
object_list.append(('/'.join(path.split('/')[2:]), object))
except:
import pdb
pdb.set_trace()
for relative_url, object in object_list:
# Browse all items stored
for relative_url, object in getattr(self, archive_variable).items():
object = portal.unrestrictedTraverse(relative_url)
container_path = relative_url.split('/')[0:-1]
object_id = relative_url.split('/')[-1]
......@@ -483,14 +503,16 @@ class ObjectTemplateItem(BaseTemplateItem):
# Found _btsave_ object
btsave_id_list.append(new_object_id)
compare_object_couple_list.append(
(object, portal.unrestrictedTraverse(
container_path+[new_object_id])))
(portal.unrestrictedTraverse(container_path+[object_id]),
portal.unrestrictedTraverse(container_path+[new_object_id])))
# (object, portal.unrestrictedTraverse(
# container_path+[new_object_id])))
n += 1
new_object_id = '%s_btsave_%s' % (object_id, n)
if n == 1:
result += "$$$ Added: %s $$$\n" % \
('/'.join(container_path+[object_id]))
result += '%s\n' % ('-'*80)
# if n == 1:
# result += "$$$ Added: %s $$$\n" % \
# ('/'.join(container_path+[object_id]))
# result += '%s\n' % ('-'*80)
# Find all objects to compare
deep = 0
while deep != max_deep:
......@@ -876,8 +898,13 @@ class PortalTypeTemplateItem(ObjectTemplateItem):
result = ObjectTemplateItem.diff(self, verbose=verbose, **kw)
# Compare chains
container_ids = self.portal_types.objectIds()
if (getattr(self, 'template_format_version', 0)) == 0:
for object in self._archive.values():
try:
object_id = object.id
except:
import pdb
pdb.set_trace()
object_chain = self.portal_workflow.getChainFor(object_id)
n = 1
new_object_id = '%s_btsave_%s' % (object_id, n)
......
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