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
alecs_myu
erp5
Commits
5261391e
Commit
5261391e
authored
Dec 09, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DomainTool: small optimization of generateMultivaluedMappedValue
parent
5184f5ea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
27 deletions
+13
-27
product/ERP5/Tool/DomainTool.py
product/ERP5/Tool/DomainTool.py
+13
-27
No files found.
product/ERP5/Tool/DomainTool.py
View file @
5261391e
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#
#
##############################################################################
##############################################################################
from
collections
import
defaultdict
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
...
@@ -332,43 +333,28 @@ class DomainTool(BaseTool):
...
@@ -332,43 +333,28 @@ class DomainTool(BaseTool):
# First get the list of predicates
# First get the list of predicates
if
predicate_list
is
None
:
if
predicate_list
is
None
:
predicate_list
=
self
.
searchPredicateList
(
context
,
test
=
test
,
**
kw
)
predicate_list
=
self
.
searchPredicateList
(
context
,
test
=
test
,
**
kw
)
if
len
(
predicate_list
)
==
0
:
if
predicate_list
:
# No predicate, return None
mapped_value
=
None
else
:
# Generate tempDeliveryCell
from
Products.ERP5Type.Document
import
newTempSupplyCell
from
Products.ERP5Type.Document
import
newTempSupplyCell
mapped_value
=
newTempSupplyCell
(
self
.
getPortalObject
(),
mapped_value_property_dict
=
defaultdict
(
list
)
'new_mapped_value'
)
explanation_dict
=
defaultdict
(
dict
)
mapped_value_property_dict
=
{}
processed_dict
=
{}
explanation_dict
=
{}
# Look for each property the first predicate with unique criterion
# Look for each property the first predicate with unique criterion
# categories which defines the property
# categories which defines the property
for
predicate
in
predicate_list
:
for
predicate
in
predicate_list
:
predicate_category_list
=
\
full_prop_dict
=
explanation_dict
[
tuple
(
predicate
.
getMembershipCriterionCategoryList
())
tuple
(
predicate
.
getMembershipCriterionCategoryList
())]
for
mapped_value_property
in
predicate
.
getMappedValuePropertyList
():
for
mapped_value_property
in
predicate
.
getMappedValuePropertyList
():
prop_list
=
processed_dict
.
setdefault
(
predicate_category_list
,
[])
if
mapped_value_property
in
full_prop_dict
:
full_prop_dict
=
explanation_dict
.
setdefault
(
predicate_category_list
,
{})
if
mapped_value_property
in
prop_list
:
# we already have one value for this (categories, property)
# we already have one value for this (categories, property)
continue
continue
value
=
predicate
.
getProperty
(
mapped_value_property
)
value
=
predicate
.
getProperty
(
mapped_value_property
)
if
value
is
not
None
:
if
value
is
not
None
:
prop_list
.
append
(
mapped_value_property
)
full_prop_dict
[
mapped_value_property
]
=
value
full_prop_dict
[
mapped_value_property
]
=
value
mv_prop_list
=
\
mapped_value_property_dict
[
mapped_value_property
].
append
(
value
)
mapped_value_property_dict
.
setdefault
(
mapped_value_property
,
[])
mv_prop_list
.
append
(
value
)
if
explanation_only
:
if
explanation_only
:
return
explanation_dict
return
dict
(
explanation_dict
)
# Update mapped value
mapped_value
=
newTempSupplyCell
(
self
.
getPortalObject
(),
mapped_value
=
mapped_value
.
asContext
(
**
mapped_value_property_dict
)
'new_mapped_value'
)
mapped_value
.
__dict__
.
update
(
mapped_value_property_dict
)
return
mapped_value
return
mapped_value
...
...
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