Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
a1b3d8e0
Commit
a1b3d8e0
authored
Nov 02, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Compare states and install new_item for Business Patch Item objects
parent
36381a6e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
2 deletions
+41
-2
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+41
-2
No files found.
product/ERP5/Tool/TemplateTool.py
View file @
a1b3d8e0
...
...
@@ -2278,7 +2278,7 @@ class TemplateTool (BaseTool):
new_val
=
item
.
_getOb
(
'new_item'
)
old_val
=
item
.
_getOb
(
'old_item'
)
self
.
updateHash
(
new_val
)
s
le
f
.
updateHash
(
old_val
)
s
el
f
.
updateHash
(
old_val
)
else
:
self
.
updateHash
(
item
)
...
...
@@ -2295,7 +2295,7 @@ class TemplateTool (BaseTool):
new_val
=
item
.
_getOb
(
'new_item'
)
old_val
=
item
.
_getOb
(
'old_item'
)
self
.
updateHash
(
new_val
)
s
le
f
.
updateHash
(
old_val
)
s
el
f
.
updateHash
(
old_val
)
else
:
self
.
updateHash
(
item
)
...
...
@@ -2392,6 +2392,10 @@ class TemplateTool (BaseTool):
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)
# XXX: Comparable hash shouldn't be used for BusinessPatchItem as whole.
We can compare the old_value and new_value, but there shouldn't be hash
for the Patch Item.
"""
if
isProperty
:
obj_dict
=
object
...
...
@@ -2493,6 +2497,41 @@ class TemplateTool (BaseTool):
for
path
in
to_update_path_list
:
try
:
# Better to check for status of BusinessPatchItem separately as it
# can contain both BusinessItem as well as BusinessPropertyItem
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
if
new_item
.
getPortalType
()
==
'Business Patch Item'
:
patch_item
=
new_item
# If the value is in ZODB, then compare it to the old_value
if
'#'
in
str
(
path
):
isProperty
=
True
relative_url
,
property_id
=
path
.
split
(
'#'
)
obj
=
portal
.
restrictedTraverse
(
relative_url
)
property_value
=
obj
.
getProperty
(
property_id
)
if
not
property_value
:
raise
KeyError
property_type
=
obj
.
getPropertyType
(
property_id
)
obj
=
property_value
else
:
# If the path is path on an object and not of a property
isProperty
=
False
obj
=
portal
.
restictedTraverse
(
path
)
obj_sha
=
self
.
calculateComparableHash
(
obj
,
isProperty
)
# Get the sha of new_item from the BusinessPatchItem object
new_item_sha
=
patch_item
.
_getOb
(
'new_item'
).
getProperty
(
'item_sha'
)
old_item_sha
=
patch_item
.
_getOb
(
'old_item'
).
getProperty
(
'item_sha'
)
if
new_item_sha
==
obj_sha
:
# If the new_item in the patch is same as the one at ZODB, do
# nothing
continue
elif
old_item_sha
==
obj_sha
:
change_list
.
append
((
patch_item
.
_getOb
(
'new_item'
),
'Adding'
))
else
:
change_list
.
append
((
patch_item
.
_getOb
(
'new_item'
),
'Removing'
))
if
'#'
in
str
(
path
):
isProperty
=
True
relative_url
,
property_id
=
path
.
split
(
'#'
)
...
...
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