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
2e0790be
Commit
2e0790be
authored
Sep 01, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Add rebuildBusinessManager to have choice while rebuilding
parent
8b2e45ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
9 deletions
+91
-9
product/ERP5/Document/BusinessManager.py
product/ERP5/Document/BusinessManager.py
+21
-9
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+70
-0
No files found.
product/ERP5/Document/BusinessManager.py
View file @
2e0790be
...
...
@@ -469,15 +469,27 @@ class BusinessManager(Folder):
LOG
(
'Business Manager'
,
INFO
,
'Building Business Manager'
)
removable_sub_object_path_list
=
kw
.
get
(
'removable_sub_object_path'
,
[])
removable_property_dict
=
kw
.
get
(
'removable_property'
,
{})
if
not
no_action
:
self
.
storeTemplateData
(
isBuild
=
True
,
**
kw
)
for
path_item
in
self
.
objectValues
():
kwargs
=
{}
item_path
=
path_item
.
getProperty
(
'item_path'
)
kwargs
[
'removable_property_list'
]
=
removable_property_dict
.
get
(
item_path
,
[])
kwargs
[
'remove_sub_objects'
]
=
item_path
in
removable_sub_object_path_list
path_item
.
build
(
self
,
**
kwargs
)
return
self
# Now, we need to put a check here for returning whih objects should be
# updated during rebuild of BM
checkNeeded
=
kw
.
get
(
'checkNeeded'
,
False
)
# Build all paths if there is no check required(i.e, its a new build action)
if
not
checkNeeded
:
if
not
no_action
:
self
.
storeTemplateData
(
isBuild
=
True
,
**
kw
)
for
path_item
in
self
.
objectValues
():
kwargs
=
{}
item_path
=
path_item
.
getProperty
(
'item_path'
)
kwargs
[
'removable_property_list'
]
=
removable_property_dict
.
get
(
item_path
,
[])
kwargs
[
'remove_sub_objects'
]
=
item_path
in
removable_sub_object_path_list
path_item
.
build
(
self
,
**
kwargs
)
return
self
else
:
item_path_list
=
kw
.
get
(
'item_path_list'
,
[])
if
item_path_list
:
for
path
in
item_path_list
:
item
=
self
.
getBusinessItemByPath
(
path
)
item
.
build
(
self
)
return
self
def
flattenBusinessManager
(
self
):
"""
...
...
product/ERP5/Tool/TemplateTool.py
View file @
2e0790be
...
...
@@ -1933,6 +1933,76 @@ class TemplateTool (BaseTool):
bm
.
setStatus
(
'installed'
)
def
rebuildBusinessManager
(
self
,
bm
):
"""
Compare the sub-objects in the Business Manager to the previous built
state to give user powet to decide on which item to rebuild.
"""
checkNeeded
=
True
changed_path_list
=
[]
if
bm
.
getBuildingState
()
not
in
[
'built'
,
'modified'
]:
# In case the building_state is not built, we build the BM without
# comparing anything
checkNeeded
=
False
return
checkNeeded
,
changed_path_list
portal
=
self
.
getPortalObject
()
for
item
in
bm
.
objectValues
():
# Check for the change compared to old building state, i.e, if there is
# some change made at ZODB state(it also count changes made due to
# change while installation of other BM)
path
=
item
.
getProperty
(
'item_path'
)
try
:
if
item
.
isProperty
:
# Get the value for Business Property Item
value
=
item
.
getProperty
(
'item_property_value'
)
# Get the value at ZODB
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
obj
=
property_value
else
:
# Get the value of the Business Path Item
value_list
=
item
.
objectValues
()
if
value_list
:
value
=
value_list
[
0
]
else
:
# If there is no value, it means the path_item is new, thus no
# need to comapre hash and check anything
changed_path_list
.
append
((
path
,
'New'
))
continue
# Get the object at ZODB
obj
=
portal
.
restrictedTraverse
(
path
)
# Calculate hash for value at ZODB
obj_sha
=
self
.
calculateComparableHash
(
obj
,
item
.
isProperty
)
# Calculate hash for value at property_value
item_sha
=
self
.
calculateComparableHash
(
value
,
item
.
isProperty
)
# Compare the hash with the item hash
if
obj_sha
!=
item_sha
:
changed_path_list
.
append
((
path
,
'Changed'
))
else
:
changed_path_list
.
append
((
path
,
'Unchanged'
))
# KeyError is raised in case the value/object has been deleted at ZODB
except
KeyError
:
changed_path_list
.
append
((
path
,
'Deleted'
))
return
checkNeeded
,
changed_path_list
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'updateInstallationState'
)
def
compareInstallationState
(
self
,
bm_list
):
...
...
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