Commit ca9709c6 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config

parent 69b2793b
...@@ -1772,20 +1772,24 @@ class TemplateTool (BaseTool): ...@@ -1772,20 +1772,24 @@ class TemplateTool (BaseTool):
def calculateComparableHash(self, object): def calculateComparableHash(self, object):
""" """
Remove some attributes before comparing hashses Remove some attributes before comparing hashses
and return hash of the comparable object dict and return hash of the comparable object dict, in case the object is
an erp5 object.
Use shallow copy of the dict of the object at ZODB after removing Use shallow copy of the dict of the object at ZODB after removing
attributes which changes at small updation, like workflow_history, attributes which changes at small updation, like workflow_history,
uid, volatile attributes(which starts with _v) uid, volatile attributes(which starts with _v)
""" """
obj_dict = object.__dict__.copy() if object.__class__.__name__ == 'PersistentMapping':
removable_attributes = [attr for attr obj_dict = object
in obj_dict.keys() else:
if attr.startswith('_v')] obj_dict = object.__dict__.copy()
removable_attributes = [attr for attr
in obj_dict.keys()
if attr.startswith('_v')]
removable_attributes.append('uid') removable_attributes.append('uid')
for attr in removable_attributes: for attr in removable_attributes:
del obj_dict[attr] del obj_dict[attr]
obj_sha = hash(pprint.pformat(obj_dict)) obj_sha = hash(pprint.pformat(obj_dict))
return obj_sha return obj_sha
...@@ -1801,7 +1805,28 @@ class TemplateTool (BaseTool): ...@@ -1801,7 +1805,28 @@ class TemplateTool (BaseTool):
for path in to_update_path_list: for path in to_update_path_list:
try: try:
obj = portal.restrictedTraverse(path) if '#' in str(path):
relative_url, property_id = path.split('#')
obj = portal.restrictedTraverse(relative_url)
property_value = obj.getProperty(property_id)
# If the value at ZODB for the property is none, raise KeyError
# This is important to have compatibility between the way we check
# path as well as property. Otherwise, if we install a new property,
# we are always be getting an Error that there is change made at
# ZODB for this property
if not property_value:
raise KeyError
property_type = obj.getPropertyType(property_id)
# Create a persistent object to compare the hash
value = PersistentMapping()
value['name'] = property_id
value['type'] = property_type
value['value'] = property_value
obj = value
else:
obj = portal.restrictedTraverse(path)
obj_sha = self.calculateComparableHash(obj) obj_sha = self.calculateComparableHash(obj)
# Get item at old state # Get item at old state
......
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