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
1
Merge Requests
1
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
Boxiang Sun
erp5
Commits
8af6f860
Commit
8af6f860
authored
Oct 11, 2012
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify and clean up buildConfiguration
- Simplify the code and Minor Optimization for sort
parent
f309c553
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
35 deletions
+12
-35
product/ERP5Configurator/Document/BusinessConfiguration.py
product/ERP5Configurator/Document/BusinessConfiguration.py
+12
-35
No files found.
product/ERP5Configurator/Document/BusinessConfiguration.py
View file @
8af6f860
...
@@ -27,13 +27,10 @@
...
@@ -27,13 +27,10 @@
#
#
##############################################################################
##############################################################################
import
time
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Globals
import
PersistentMapping
from
Globals
import
PersistentMapping
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
zLOG
import
LOG
,
INFO
from
cStringIO
import
StringIO
from
Products.ERP5Configurator.Tool.ConfiguratorTool
import
_validateFormToRequest
from
Products.ERP5Configurator.Tool.ConfiguratorTool
import
_validateFormToRequest
from
Products.ERP5.Document.Item
import
Item
from
Products.ERP5.Document.Item
import
Item
...
@@ -262,19 +259,6 @@ class BusinessConfiguration(Item):
...
@@ -262,19 +259,6 @@ class BusinessConfiguration(Item):
form
=
getattr
(
self
,
self
.
getNextTransition
().
getTransitionFormId
())
form
=
getattr
(
self
,
self
.
getNextTransition
().
getTransitionFormId
())
return
_validateFormToRequest
(
form
,
REQUEST
,
**
kw
)
return
_validateFormToRequest
(
form
,
REQUEST
,
**
kw
)
#############
## misc ##
#############
security
.
declarePrivate
(
'_getConfigurationStack'
)
def
_getConfigurationStack
(
self
):
""" Return list of created by client configuration save objects
sort on id which is an integer. """
result
=
self
.
objectValues
(
'ERP5 Configuration Save'
)
result
=
map
(
None
,
result
)
result
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
getIntIndex
(
x
.
getIntId
()),
y
.
getIntIndex
(
y
.
getIntId
())))
return
result
security
.
declarePrivate
(
'_getConfSaveForStateFromWorkflowHistory'
)
security
.
declarePrivate
(
'_getConfSaveForStateFromWorkflowHistory'
)
def
_getConfSaveForStateFromWorkflowHistory
(
self
):
def
_getConfSaveForStateFromWorkflowHistory
(
self
):
""" Get from workflow history configuration save for this state """
""" Get from workflow history configuration save for this state """
...
@@ -282,8 +266,7 @@ class BusinessConfiguration(Item):
...
@@ -282,8 +266,7 @@ class BusinessConfiguration(Item):
current_state
=
self
.
getCurrentStateValue
()
current_state
=
self
.
getCurrentStateValue
()
transition
=
self
.
getNextTransition
()
transition
=
self
.
getNextTransition
()
next_state
=
self
.
unrestrictedTraverse
(
transition
.
getDestination
())
next_state
=
self
.
unrestrictedTraverse
(
transition
.
getDestination
())
workflow_history
=
current_state
.
getWorkflowHistory
(
self
)
for
wh
in
current_state
.
getWorkflowHistory
(
self
):
for
wh
in
workflow_history
:
if
next_state
==
self
.
unrestrictedTraverse
(
wh
[
'current_state'
]):
if
next_state
==
self
.
unrestrictedTraverse
(
wh
[
'current_state'
]):
configuration_save
=
self
.
unrestrictedTraverse
(
wh
[
'configuration_save_url'
])
configuration_save
=
self
.
unrestrictedTraverse
(
wh
[
'configuration_save_url'
])
return
configuration_save
return
configuration_save
...
@@ -339,12 +322,11 @@ class BusinessConfiguration(Item):
...
@@ -339,12 +322,11 @@ class BusinessConfiguration(Item):
security
.
declareProtected
(
Permissions
.
View
,
'getGlobalConfigurationAttr'
)
security
.
declareProtected
(
Permissions
.
View
,
'getGlobalConfigurationAttr'
)
def
getGlobalConfigurationAttr
(
self
,
key
,
default
=
None
):
def
getGlobalConfigurationAttr
(
self
,
key
,
default
=
None
):
""" Get global business configuration attribute. """
""" Get global business configuration attribute. """
global_configuration_attributes
=
getattr
(
self
,
'_global_configuration_attributes'
,
{})
return
getattr
(
self
,
'_global_configuration_attributes'
,
{}).
get
(
key
,
default
)
return
global_configuration_attributes
.
get
(
key
,
default
)
############# Instance and Business Configuration ########################
############# Instance and Business Configuration ########################
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'buildConfiguration'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'buildConfiguration'
)
def
buildConfiguration
(
self
,
execute_after_setup_script
=
1
):
def
buildConfiguration
(
self
):
"""
"""
Build list of business templates according to already saved
Build list of business templates according to already saved
Configuration Saves (i.e. user input).
Configuration Saves (i.e. user input).
...
@@ -355,13 +337,13 @@ class BusinessConfiguration(Item):
...
@@ -355,13 +337,13 @@ class BusinessConfiguration(Item):
after_method_id
=
[
"updateBusinessTemplateFromUrl"
,
after_method_id
=
[
"updateBusinessTemplateFromUrl"
,
"recursiveImmediateReindexObject"
,
"recursiveImmediateReindexObject"
,
"immediateReindexObject"
])
"immediateReindexObject"
])
start
=
time
.
time
()
LOG
(
"CONFIGURATOR"
,
INFO
,
'Build process started for %s'
%
self
.
getRelativeUrl
())
# build
# build
for
configuration_save
in
self
.
_getConfigurationStack
():
configuration_save_list
=
self
.
contentValues
(
portal_type
=
'Configuration Save'
)
configuration_save_list
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
getIntIndex
(
x
.
getIntId
()),
y
.
getIntIndex
(
y
.
getIntId
())))
for
configuration_save
in
configuration_save_list
:
# XXX: check which items are configure-able
# XXX: check which items are configure-able
configuration_item_list
=
[
x
for
x
in
configuration_save
.
contentValues
()]
configuration_item_list
=
configuration_save
.
contentValues
()
configuration_item_list
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
getIntId
(),
y
.
getIntId
()))
configuration_item_list
.
sort
(
lambda
x
,
y
:
cmp
(
x
.
getIntId
(),
y
.
getIntId
()))
for
configurator_item
in
configuration_item_list
:
for
configurator_item
in
configuration_item_list
:
configurator_item
.
activate
(
**
kw
).
build
(
self
.
getRelativeUrl
())
configurator_item
.
activate
(
**
kw
).
build
(
self
.
getRelativeUrl
())
...
@@ -369,16 +351,11 @@ class BusinessConfiguration(Item):
...
@@ -369,16 +351,11 @@ class BusinessConfiguration(Item):
kw
[
"tag"
]
=
"configurator_item_%s_%s"
%
(
configurator_item
.
getId
(),
kw
[
"tag"
]
=
"configurator_item_%s_%s"
%
(
configurator_item
.
getId
(),
configurator_item
.
getUid
())
configurator_item
.
getUid
())
LOG
(
'CONFIGURATOR'
,
INFO
,
kw
[
"tag"
]
=
"final_configuration_step_%s"
%
self
.
getId
()
'Build process started for %s ended after %.02fs'
%
(
self
.
getRelativeUrl
(),
kw
[
"after_method_id"
]
=
[
"build"
,
'immediateReindexObject'
,
\
time
.
time
()
-
start
))
"recursiveImmediateReindexObject"
]
if
execute_after_setup_script
:
kw
[
"tag"
]
=
"final_configuration_step_%s"
%
self
.
getId
()
kw
[
"after_method_id"
]
=
[
"build"
,
'immediateReindexObject'
,
\
"recursiveImmediateReindexObject"
]
self
.
activate
(
**
kw
).
ERP5Site_afterConfigurationSetup
()
self
.
activate
(
**
kw
).
ERP5Site_afterConfigurationSetup
()
if
self
.
portal_workflow
.
isTransitionPossible
(
self
,
'install'
):
if
self
.
portal_workflow
.
isTransitionPossible
(
self
,
'install'
):
self
.
activate
(
after_tag
=
kw
[
"tag"
]).
install
()
self
.
activate
(
after_tag
=
kw
[
"tag"
]).
install
()
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