Commit ca9709c6 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config

parent 69b2793b
...@@ -1772,12 +1772,16 @@ class TemplateTool (BaseTool): ...@@ -1772,12 +1772,16 @@ 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)
""" """
if object.__class__.__name__ == 'PersistentMapping':
obj_dict = object
else:
obj_dict = object.__dict__.copy() obj_dict = object.__dict__.copy()
removable_attributes = [attr for attr removable_attributes = [attr for attr
in obj_dict.keys() in obj_dict.keys()
...@@ -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:
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 = 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