Commit 38731317 authored by Ayush Tiwari's avatar Ayush Tiwari

DiffTool: removePropertyList function should be working same for both ERP5...

DiffTool: removePropertyList function should be working same for both ERP5 object and dictionaries of ERP5 object properties

Before we use to neglect removing some properties from ERP5 object properties' dict, which led to error in case of use
of DiffTool for Historical Revisions dict. Thus, its important for removeProperties function to act similar in both
cases.

Also, add `base_data` in attribute_set to be removed because `data`, `base_data` and `text_content` are same
parent df17ebbc
...@@ -232,11 +232,14 @@ class PortalPatch: ...@@ -232,11 +232,14 @@ class PortalPatch:
""" """
if isinstance(obj, dict): if isinstance(obj, dict):
obj_dict = obj.copy() obj_dict = obj.copy()
export = False # Try to get the classname and module name from the dict
class_name = obj.get('portal_type', '')
module_name = obj.get('__module__', '')
else: else:
obj._p_activate() obj._p_activate()
klass = obj.__class__ klass = obj.__class__
classname = klass.__name__ class_name = klass.__name__
module_name = klass.__module__
obj_dict = obj.showDict().copy() obj_dict = obj.showDict().copy()
attribute_set = {'_dav_writelocks', '_filepath', '_owner', '_related_index', attribute_set = {'_dav_writelocks', '_filepath', '_owner', '_related_index',
...@@ -244,7 +247,7 @@ class PortalPatch: ...@@ -244,7 +247,7 @@ class PortalPatch:
'__ac_local_roles__', '__ac_local_roles_group_id_dict__', '__ac_local_roles__', '__ac_local_roles_group_id_dict__',
'workflow_history', 'subject_set_uid_dict', 'security_uid_dict', 'workflow_history', 'subject_set_uid_dict', 'security_uid_dict',
'filter_dict', '_max_uid', 'isIndexable', 'id', 'modification_date', 'filter_dict', '_max_uid', 'isIndexable', 'id', 'modification_date',
'data'} 'data', 'base_data'}
# Update the list of properties which were explicitly given in parameters # Update the list of properties which were explicitly given in parameters
if property_list: if property_list:
...@@ -264,13 +267,13 @@ class PortalPatch: ...@@ -264,13 +267,13 @@ class PortalPatch:
attribute_set.update(('func_code', 'func_defaults', '_code', attribute_set.update(('func_code', 'func_defaults', '_code',
'_lazy_compilation', 'Python_magic', 'errors', '_lazy_compilation', 'Python_magic', 'errors',
'warnings', '_proxy_roles')) 'warnings', '_proxy_roles'))
elif classname in ('File', 'Image'): elif class_name in ('File', 'Image'):
attribute_set.update(('_EtagSupport__etag', 'size')) attribute_set.update(('_EtagSupport__etag', 'size'))
elif classname == 'SQL' and klass.__module__ == 'Products.ZSQLMethods.SQL': elif class_name == 'SQL' and module_name == 'Products.ZSQLMethods.SQL':
attribute_set.update(('_arg', 'template')) attribute_set.update(('_arg', 'template'))
elif interfaces.IIdGenerator.providedBy(obj): elif interfaces.IIdGenerator.providedBy(obj):
attribute_set.update(('last_max_id_dict', 'last_id_dict')) attribute_set.update(('last_max_id_dict', 'last_id_dict'))
elif classname == 'Types Tool' and klass.__module__ == 'erp5.portal_type': elif class_name == 'Types Tool' and module_name == 'erp5.portal_type':
attribute_set.add('type_provider_list') attribute_set.add('type_provider_list')
for attribute in list(obj_dict.keys()): for attribute in list(obj_dict.keys()):
......
  • Also, add base_data in attribute_set to be removed because data, base_data and text_content are same

    FYI, this is not always the case, the difference between data and base_data is not well know (at least in erp5_dms), but in essence, if you upload a CSV file in a Spreadsheet portal type in document module:

    • data is the CSV as you uploaded
    • base_data is the ODS conversion of the CSV, because ODS is "base format" for CSV.

    This means that after uploading a new file, both data and base_data will change (and base_data change in another transaction because base conversion is deferred), in that case, it's probably better to show only diff.

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