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
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
erp5
Commits
ab33c4a0
Commit
ab33c4a0
authored
Aug 10, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Remove useless functions based on old format of Business Manager
parent
06ac4c84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
180 deletions
+0
-180
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+0
-180
No files found.
product/ERP5/Tool/TemplateTool.py
View file @
ab33c4a0
...
@@ -2273,186 +2273,6 @@ class TemplateTool (BaseTool):
...
@@ -2273,186 +2273,6 @@ class TemplateTool (BaseTool):
return
error_list
return
error_list
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'createNewInstallationState'
)
def
createNewInstallationState
(
self
,
bm_list
,
old_installation_state
):
"""
Combines multiple BM to form single BM which would be the new
installtion state
"""
new_bm_list
=
bm_list
[:]
# Create a list of path and hashes to be used for comparison
path_list
=
[]
sha_list
=
[]
forbidden_bm_title_list
=
[
'Installation State'
,]
for
bm
in
new_bm_list
:
forbidden_bm_title_list
.
append
(
bm
.
title
)
for
item
in
bm
.
path_item_list
:
path_list
.
append
(
item
.
path
)
sha_list
.
append
(
item
.
sha
)
installed_bm_list
=
[
l
for
l
in
self
.
getInstalledBusinessManagerList
()
if
l
.
title
not
in
forbidden_bm_title_list
]
new_bm_list
.
extend
(
installed_bm_list
)
# Summation should also consider arithmetic on the Business Item(s)
# having same path and layer and combine them.
combinedBM
=
self
.
newContent
(
portal_type
=
'Business Manager'
,
title
=
'Combined Business Manager'
)
combinedBM
.
build
()
new_bm_list
.
insert
(
0
,
combinedBM
)
combinedBM
=
reduce
(
lambda
x
,
y
:
x
+
y
,
new_bm_list
)
final_path_list
=
combinedBM
.
getTemplatePathList
()
final_path_item_list
=
[]
final_path_item_list
.
extend
(
combinedBM
.
_path_item_list
)
removable_sha_list
=
[]
removable_path_list
=
[]
for
item
in
old_installation_state
.
_path_item_list
:
if
item
.
path
in
path_list
and
item
.
sha
in
sha_list
:
# If there is Business Item which have no change on updation, then
# no need to reinstall it, cause in that case we prefer the changes
# at ZODB
# XXX: BAD DESIGN: Should compare both path as well as hash and keep
# them together in a dictionary,using them separately can lead to
# conflict in case two paths have same hash.
removable_sha_list
.
append
(
item
.
sha
)
removable_path_list
.
append
(
item
.
path
)
else
:
# If there is update of path item, change the sign of the last
# version of that Business Item and add it to final_path_item_list
item
.
sign
=
-
1
final_path_item_list
.
append
(
item
)
final_path_list
.
extend
(
old_installation_state
.
getTemplatePathList
())
# Remove the Business Item objects from final_path_item_list which have
# same sha and path
final_path_list
=
[
path
for
path
in
final_path_list
if
path
not
in
removable_path_list
]
final_path_item_list
=
[
item
for
item
in
final_path_item_list
if
item
.
sha
not
in
removable_sha_list
]
final_path_item_list
.
sort
(
key
=
lambda
x
:
x
.
sign
)
# Remove the old installation state
self
.
_delObject
(
old_installation_state
.
getId
())
combinedBM
.
_setTemplatePathList
(
final_path_list
)
combinedBM
.
_path_item_list
=
final_path_item_list
# Change the title of the combined BM
combinedBM
.
setTitle
(
'Installation State'
)
# XXX: We are missing the part of creating installed_BM for all the BM
# we have in bm_list, because this would be needed in case we build
# Business Manager again.
# Reduce the final Business Manager
#combinedBM.reduceBusinessManager()
return
combinedBM
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'compareInstallationStateWithOFS'
)
def
compareInstallationStateWithOFS
(
self
,
buildBM
,
new_installation_state
,
old_installation_state
):
"""
Compare the buildBM and to be installed BM and show the changes in a way
it can be notified or installed.
1. Compare the hash of the objects and create a diff file in case of
conflict
2. If forced installation, delete the old object and install the ones
from update Business Manager
Returns:
- has_confict: True , if there is a conflict between the 2 BMs
- DiffFile: In case there is conflict between the two states
"""
# XXX: BAD DESIGN: Should compare both path as well as hash, just path
# can lead to conflict in case two paths have same sha.
built_item_dict
=
{
item
.
path
:
item
.
sha
for
item
in
buildBM
.
_path_item_list
}
old_item_dict
=
{
item
.
path
:
item
.
sha
for
item
in
old_installation_state
.
_path_item_list
}
# For creating new_item_dict, we have to take use of template_path_list
# property as there can be case where we have path but not path_item as
# the new state already gets filtered while creation
new_item_dict
=
{
item
.
path
:
item
.
sha
for
item
in
new_installation_state
.
_path_item_list
if
item
.
sign
==
1
}
build_sha_list
=
built_item_dict
.
values
()
final_item_list
=
[]
for
item
in
new_installation_state
.
_path_item_list
:
if
item
.
sign
==
1
:
if
path
in
old_item_dict
.
keys
():
if
old_item_dict
[
path
]
==
item
.
sha
:
pass
for
item
in
new_installation_state
.
_path_item_list
:
if
item
.
sha
in
build_sha_list
and
item
.
sign
==
1
:
# No need to install value which we already have
continue
else
:
final_item_list
.
append
(
item
)
new_installation_state
.
_path_item_list
=
final_item_list
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'compareMultipleBusinessManager'
)
def
compareBusinessManager
(
self
,
new_bm
,
old_bm
):
"""
Compare two business manager and return a new Business manager based on
the difference. This is specially required to compare two versions of
Business Manager(s).
"""
compared_bm
=
new_bm
-
old_bm
# Return the subtraction of the Business Manager
return
compared_bm
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'cleanInstallationState'
)
def
cleanInstallationState
(
self
,
installation_state
):
"""
Installation State is the Business Manager which has been installed
Cleaning means removal of all the Business Item with negative sign
**WARNING**:This should only be done after installing the Business Manager
"""
if
installation_state
.
getStatus
()
!=
'installed'
:
LOG
(
'WARNING'
,
0
,
'Trying to clean installation state before installing'
)
raise
ValueError
,
"Can't clean before installing"
final_path_item_list
=
[]
for
item
in
installation_state
.
_path_item_list
:
if
item
.
sign
==
1
:
final_path_item_list
.
append
(
item
)
installation_state
.
_path_item_list
=
final_path_item_list
def
getInstalledBusinessManagerList
(
self
):
def
getInstalledBusinessManagerList
(
self
):
bm_list
=
self
.
objectValues
(
portal_type
=
'Business Manager'
)
bm_list
=
self
.
objectValues
(
portal_type
=
'Business Manager'
)
installed_bm_list
=
[
bm
for
bm
in
bm_list
if
bm
.
getStatus
()
==
'installed'
]
installed_bm_list
=
[
bm
for
bm
in
bm_list
if
bm
.
getStatus
()
==
'installed'
]
...
...
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