Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
ca9709c6
Commit
ca9709c6
authored
Mar 31, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config
parent
69b2793b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+34
-9
No files found.
product/ERP5/Tool/TemplateTool.py
View file @
ca9709c6
...
...
@@ -1772,20 +1772,24 @@ class TemplateTool (BaseTool):
def
calculateComparableHash
(
self
,
object
):
"""
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
attributes which changes at small updation, like workflow_history,
uid, volatile attributes(which starts with _v)
"""
obj_dict
=
object
.
__dict__
.
copy
()
removable_attributes
=
[
attr
for
attr
in
obj_dict
.
keys
()
if
attr
.
startswith
(
'_v'
)]
if
object
.
__class__
.
__name__
==
'PersistentMapping'
:
obj_dict
=
object
else
:
obj_dict
=
object
.
__dict__
.
copy
()
removable_attributes
=
[
attr
for
attr
in
obj_dict
.
keys
()
if
attr
.
startswith
(
'_v'
)]
removable_attributes
.
append
(
'uid'
)
for
attr
in
removable_attributes
:
del
obj_dict
[
attr
]
removable_attributes
.
append
(
'uid'
)
for
attr
in
removable_attributes
:
del
obj_dict
[
attr
]
obj_sha
=
hash
(
pprint
.
pformat
(
obj_dict
))
return
obj_sha
...
...
@@ -1801,7 +1805,28 @@ class TemplateTool (BaseTool):
for
path
in
to_update_path_list
:
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
)
# Get item at old state
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment