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
d0657be9
Commit
d0657be9
authored
May 03, 2017
by
Ayush Tiwari
Committed by
Ayush Tiwari
Nov 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add BusinessPropertyItem for saving values of properties
parent
4f9f1418
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
219 deletions
+123
-219
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+99
-207
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+24
-12
No files found.
product/ERP5/Document/BusinessManager.py
View file @
d0657be9
This diff is collapsed.
Click to expand it.
product/ERP5/Tool/TemplateTool.py
View file @
d0657be9
...
@@ -1775,9 +1775,15 @@ class TemplateTool (BaseTool):
...
@@ -1775,9 +1775,15 @@ class TemplateTool (BaseTool):
# thus all the BusinessItem sub-objects should have single value
# thus all the BusinessItem sub-objects should have single value
# Update hashes of item in old state before installation
# Update hashes of item in old state before installation
for
item
in
old_installation_state
.
objectValues
():
for
item
in
old_installation_state
.
objectValues
():
if
item
.
isProperty
:
value_list
=
item
.
getProperty
(
'value'
)
else
:
value_list
=
item
.
objectValues
()
value_list
=
item
.
objectValues
()
if
value_list
:
if
value_list
:
item
.
setProperty
(
'item_sha'
,
self
.
calculateComparableHash
(
value_list
[
0
]))
item
.
setProperty
(
'item_sha'
,
self
.
calculateComparableHash
(
value_list
[
0
],
item
.
isProperty
,
))
# Path Item List for installation_process should be the difference between
# Path Item List for installation_process should be the difference between
# old and new installation state
# old and new installation state
...
@@ -1785,7 +1791,15 @@ class TemplateTool (BaseTool):
...
@@ -1785,7 +1791,15 @@ class TemplateTool (BaseTool):
# If the path has been removed, then add it with sign = -1
# If the path has been removed, then add it with sign = -1
old_item
=
old_installation_state
.
getBusinessItemByPath
(
item
.
getProperty
(
'item_path'
))
old_item
=
old_installation_state
.
getBusinessItemByPath
(
item
.
getProperty
(
'item_path'
))
# Calculate sha for the items in new_insatallation_state
# Calculate sha for the items in new_insatallation_state
item
.
setProperty
(
'item_sha'
,
self
.
calculateComparableHash
(
item
.
objectValues
()[
0
]))
import
pdb
;
pdb
.
set_trace
()
if
item
.
isProperty
:
value
=
item
.
getProperty
(
'value'
)
else
:
value
=
item
.
objectValues
()[
0
]
item
.
setProperty
(
'item_sha'
,
self
.
calculateComparableHash
(
value
,
item
.
isProperty
,
))
if
old_item
:
if
old_item
:
# If the old_item exists, we match the hashes and if it differs, then
# If the old_item exists, we match the hashes and if it differs, then
# add the new item
# add the new item
...
@@ -1810,7 +1824,7 @@ class TemplateTool (BaseTool):
...
@@ -1810,7 +1824,7 @@ class TemplateTool (BaseTool):
installMultipleBusinessManager
=
updateInstallationState
installMultipleBusinessManager
=
updateInstallationState
def
calculateComparableHash
(
self
,
object
):
def
calculateComparableHash
(
self
,
object
,
isProperty
=
False
):
"""
"""
Remove some attributes before comparing hashses
Remove some attributes before comparing hashses
and return hash of the comparable object dict, in case the object is
and return hash of the comparable object dict, in case the object is
...
@@ -1820,7 +1834,7 @@ class TemplateTool (BaseTool):
...
@@ -1820,7 +1834,7 @@ class TemplateTool (BaseTool):
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'
:
if
isProperty
:
obj_dict
=
object
obj_dict
=
object
else
:
else
:
obj_dict
=
object
.
__dict__
.
copy
()
obj_dict
=
object
.
__dict__
.
copy
()
...
@@ -1830,6 +1844,7 @@ class TemplateTool (BaseTool):
...
@@ -1830,6 +1844,7 @@ class TemplateTool (BaseTool):
removable_attributes
.
append
(
'uid'
)
removable_attributes
.
append
(
'uid'
)
removable_attributes
.
append
(
'_owner'
)
removable_attributes
.
append
(
'_owner'
)
removable_attributes
.
append
(
'isIndexable'
)
for
attr
in
removable_attributes
:
for
attr
in
removable_attributes
:
try
:
try
:
del
obj_dict
[
attr
]
del
obj_dict
[
attr
]
...
@@ -1851,6 +1866,7 @@ class TemplateTool (BaseTool):
...
@@ -1851,6 +1866,7 @@ class TemplateTool (BaseTool):
try
:
try
:
if
'#'
in
str
(
path
):
if
'#'
in
str
(
path
):
isProperty
=
True
relative_url
,
property_id
=
path
.
split
(
'#'
)
relative_url
,
property_id
=
path
.
split
(
'#'
)
obj
=
portal
.
restrictedTraverse
(
relative_url
)
obj
=
portal
.
restrictedTraverse
(
relative_url
)
property_value
=
obj
.
getProperty
(
property_id
)
property_value
=
obj
.
getProperty
(
property_id
)
...
@@ -1863,16 +1879,12 @@ class TemplateTool (BaseTool):
...
@@ -1863,16 +1879,12 @@ class TemplateTool (BaseTool):
if
not
property_value
:
if
not
property_value
:
raise
KeyError
raise
KeyError
property_type
=
obj
.
getPropertyType
(
property_id
)
property_type
=
obj
.
getPropertyType
(
property_id
)
# Create a persistent object to compare the hash
obj
=
property_value
value
=
PersistentMapping
()
value
[
'name'
]
=
property_id
value
[
'type'
]
=
property_type
value
[
'value'
]
=
property_value
obj
=
value
else
:
else
:
isProperty
=
False
obj
=
portal
.
restrictedTraverse
(
path
)
obj
=
portal
.
restrictedTraverse
(
path
)
obj_sha
=
self
.
calculateComparableHash
(
obj
)
obj_sha
=
self
.
calculateComparableHash
(
obj
,
isProperty
)
# Get item at old state
# Get item at old state
old_item
=
old_state
.
getBusinessItemByPath
(
path
)
old_item
=
old_state
.
getBusinessItemByPath
(
path
)
...
...
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