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
Matevz Golob
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
Hide 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 @@
#
##############################################################################
from
collections
import
defaultdict
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
from
Products.ERP5Type
import
Permissions
...
...
@@ -332,44 +333,29 @@ class DomainTool(BaseTool):
# First get the list of predicates
if
predicate_list
is
None
:
predicate_list
=
self
.
searchPredicateList
(
context
,
test
=
test
,
**
kw
)
if
len
(
predicate_list
)
==
0
:
# No predicate, return None
mapped_value
=
None
else
:
# Generate tempDeliveryCell
if
predicate_list
:
from
Products.ERP5Type.Document
import
newTempSupplyCell
mapped_value
=
newTempSupplyCell
(
self
.
getPortalObject
(),
'new_mapped_value'
)
mapped_value_property_dict
=
{}
processed_dict
=
{}
explanation_dict
=
{}
mapped_value_property_dict
=
defaultdict
(
list
)
explanation_dict
=
defaultdict
(
dict
)
# Look for each property the first predicate with unique criterion
# categories which defines the property
for
predicate
in
predicate_list
:
predicate_category_list
=
\
tuple
(
predicate
.
getMembershipCriterionCategoryList
())
full_prop_dict
=
explanation_dict
[
tuple
(
predicate
.
getMembershipCriterionCategoryList
())]
for
mapped_value_property
in
predicate
.
getMappedValuePropertyList
():
prop_list
=
processed_dict
.
setdefault
(
predicate_category_list
,
[])
full_prop_dict
=
explanation_dict
.
setdefault
(
predicate_category_list
,
{})
if
mapped_value_property
in
prop_list
:
if
mapped_value_property
in
full_prop_dict
:
# we already have one value for this (categories, property)
continue
value
=
predicate
.
getProperty
(
mapped_value_property
)
if
value
is
not
None
:
prop_list
.
append
(
mapped_value_property
)
full_prop_dict
[
mapped_value_property
]
=
value
mv_prop_list
=
\
mapped_value_property_dict
.
setdefault
(
mapped_value_property
,
[])
mv_prop_list
.
append
(
value
)
mapped_value_property_dict
[
mapped_value_property
].
append
(
value
)
if
explanation_only
:
return
explanation_dict
# Update mapped value
mapped_value
=
mapped_value
.
asContext
(
**
mapped_value_property_dict
)
return
mapped_value
return
dict
(
explanation_dict
)
mapped_value
=
newTempSupplyCell
(
self
.
getPortalObject
(),
'new_mapped_value'
)
mapped_value
.
__dict__
.
update
(
mapped_value_property_dict
)
return
mapped_value
def
getChildDomainValueList
(
self
,
parent
,
**
kw
):
...
...
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