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
3eecf089
Commit
3eecf089
authored
Mar 20, 2017
by
Ayush Tiwari
Committed by
Ayush Tiwari
Nov 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_config: Instead of raising error one by one, collect in error_list
parent
1deb07a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+13
-10
No files found.
product/ERP5/Tool/TemplateTool.py
View file @
3eecf089
...
@@ -33,6 +33,7 @@ from App.config import getConfiguration
...
@@ -33,6 +33,7 @@ from App.config import getConfiguration
import
os
import
os
import
shutil
import
shutil
import
sys
import
sys
import
hashlib
from
Acquisition
import
Implicit
,
Explicit
from
Acquisition
import
Implicit
,
Explicit
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
...
@@ -1755,12 +1756,15 @@ class TemplateTool (BaseTool):
...
@@ -1755,12 +1756,15 @@ class TemplateTool (BaseTool):
installation_process
.
_path_item_list
=
to_install_path_item_list
installation_process
.
_path_item_list
=
to_install_path_item_list
self
.
compareOldStateToOFS
(
installation_process
,
old_installation_state
)
error_list
=
self
.
compareOldStateToOFS
(
installation_process
,
old_installation_state
)
# Change status of all BM installed
# Change status of all BM installed
for
bm
in
bm_list
:
for
bm
in
bm_list
:
bm
.
setStatus
(
'installed'
)
bm
.
setStatus
(
'installed'
)
if
error_list
:
raise
ValueError
(
' '
.
join
(
error_list
))
installMultipleBusinessManager
=
updateInstallationState
installMultipleBusinessManager
=
updateInstallationState
def
compareOldStateToOFS
(
self
,
installation_process
,
old_state
):
def
compareOldStateToOFS
(
self
,
installation_process
,
old_state
):
...
@@ -1775,20 +1779,20 @@ class TemplateTool (BaseTool):
...
@@ -1775,20 +1779,20 @@ class TemplateTool (BaseTool):
try
:
try
:
obj
=
portal
.
restrictedTraverse
(
path
)
obj
=
portal
.
restrictedTraverse
(
path
)
obj_sha
=
hashlib
.
sha256
(
obj
.
to
XML
()).
hexdigest
()
obj_sha
=
hashlib
.
sha256
(
obj
.
as
XML
()).
hexdigest
()
# Get item at old state
# Get item at old state
old_item
=
old_state
.
getBusinessItemByPath
()
old_item
=
old_state
.
getBusinessItemByPath
(
path
)
# Check if there is an object at old state at this path
# Check if there is an object at old state at this path
if
old_item
:
if
old_item
:
# Compare hash with ZODB
# Compare hash with ZODB
if
old_item
.
_sha
==
obj
.
_sha
:
if
old_item
.
_sha
==
obj_sha
:
# No change at ZODB on old item, so get the new item
# No change at ZODB on old item, so get the new item
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
# Compare new item hash with ZODB
# Compare new item hash with ZODB
if
new_item
.
_sha
==
obj
.
_sha
:
if
new_item
.
_sha
==
obj_sha
:
# If same hash, do nothing
# If same hash, do nothing
continue
continue
...
@@ -1801,28 +1805,26 @@ class TemplateTool (BaseTool):
...
@@ -1801,28 +1805,26 @@ class TemplateTool (BaseTool):
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
# Compare new item hash with ZODB
# Compare new item hash with ZODB
if
new_item
.
_sha
==
obj
.
_sha
:
if
new_item
.
_sha
==
obj_sha
:
# If same hash, do nothing
# If same hash, do nothing
continue
continue
else
:
else
:
# Raise error
# Raise error
error_list
.
append
(
'Trying to remove changes at ZODB at %s'
%
path
)
error_list
.
append
(
'Trying to remove changes at ZODB at %s'
%
path
)
raise
ValueError
(
'Trying to remove changes at ZODB at %s'
%
path
)
else
:
else
:
# Object created at ZODB by the user
# Object created at ZODB by the user
# Compare with the new_item
# Compare with the new_item
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
if
new_item
.
_sha
==
obj
.
_sha
:
if
new_item
.
_sha
==
obj_sha
:
# If same hash, do nothing
# If same hash, do nothing
continue
continue
else
:
else
:
# Raise error
# Raise error
error_list
.
append
(
'Trying to remove changes at ZODB at %s'
%
path
)
error_list
.
append
(
'Trying to remove changes at ZODB at %s'
%
path
)
raise
ValueError
(
'Trying to remove changes at ZODB at %s'
%
path
)
except
Exception
:
except
Exception
:
# Get item at old state
# Get item at old state
...
@@ -1837,13 +1839,14 @@ class TemplateTool (BaseTool):
...
@@ -1837,13 +1839,14 @@ class TemplateTool (BaseTool):
if
new_item
.
_sign
==
1
:
if
new_item
.
_sign
==
1
:
error_list
.
append
(
'Object at %s removed by user'
%
path
)
error_list
.
append
(
'Object at %s removed by user'
%
path
)
raise
ValueError
(
'Object at %s removed by user'
%
path
)
else
:
else
:
# If there is no item at old state, install the new_item
# If there is no item at old state, install the new_item
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
new_item
=
installation_process
.
getBusinessItemByPath
(
path
)
new_item
.
install
(
installation_process
)
new_item
.
install
(
installation_process
)
return
error_list
security
.
declareProtected
(
Permissions
.
ManagePortal
,
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'createNewInstallationState'
)
'createNewInstallationState'
)
def
createNewInstallationState
(
self
,
bm_list
,
old_installation_state
):
def
createNewInstallationState
(
self
,
bm_list
,
old_installation_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