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
Titouan Soulard
erp5
Commits
2b92f990
Commit
2b92f990
authored
Jul 27, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expand: optimize creation of new movements by not using propertyMap+_edit
parent
db5e05dc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
35 deletions
+12
-35
product/ERP5/MovementCollectionDiff.py
product/ERP5/MovementCollectionDiff.py
+2
-19
product/ERP5/interfaces/movement_collection_diff.py
product/ERP5/interfaces/movement_collection_diff.py
+1
-9
product/ERP5/mixin/movement_collection_updater.py
product/ERP5/mixin/movement_collection_updater.py
+9
-7
No files found.
product/ERP5/MovementCollectionDiff.py
View file @
2b92f990
...
...
@@ -45,7 +45,6 @@ class MovementCollectionDiff(object):
self
.
_deletable_movement_list
=
[]
self
.
_new_movement_list
=
[]
self
.
_updatable_movement_list
=
[]
self
.
_property_dict_dict
=
{}
def
getDeletableMovementList
(
self
):
"""
...
...
@@ -75,33 +74,17 @@ class MovementCollectionDiff(object):
def
getUpdatableMovementList
(
self
):
"""
Returns the list of movements which need
to be updated.
Returns movements which need to be updated, with properties to update
"""
return
self
.
_updatable_movement_list
def
getMovementPropertyDict
(
self
,
movement
):
"""
Returns a dict of all properties and values
to update an existing movement or to
create a new movement.
"""
# for updatable movement, property_dict is already calculated.
property_dict
=
self
.
_property_dict_dict
.
get
(
movement
)
# for new movement, property_dict should be calculated here.
if
property_dict
is
None
:
return
_getPropertyAndCategoryList
(
movement
)
else
:
return
property_dict
def
addUpdatableMovement
(
self
,
movement
,
property_dict
):
"""
Add an updatable movement to the diff definition
property_dict -- properties to update
"""
self
.
_updatable_movement_list
.
append
(
movement
)
self
.
_property_dict_dict
[
movement
]
=
property_dict
self
.
_updatable_movement_list
.
append
((
movement
,
property_dict
))
def
_getPropertyAndCategoryList
(
document
):
"""
...
...
product/ERP5/interfaces/movement_collection_diff.py
View file @
2b92f990
...
...
@@ -64,15 +64,7 @@ class IMovementCollectionDiff(Interface):
def
getUpdatableMovementList
():
"""
Returns the list of movements which need
to be updated.
"""
def
getMovementPropertyDict
(
movement
):
"""
Returns a dict of all properties and values
to update an existing movement or to
create a new movement.
Returns movements which need to be updated, with properties to update
"""
def
addUpdatableMovement
(
movement
,
property_dict
):
...
...
product/ERP5/mixin/movement_collection_updater.py
View file @
2b92f990
...
...
@@ -164,13 +164,15 @@ class MovementCollectionUpdaterMixin:
# Apply Diff
for
movement
in
movement_diff
.
getDeletableMovementList
():
movement
.
getParentValue
().
deleteContent
(
movement
.
getId
())
for
movement
in
movement_diff
.
getUpdatableMovementList
():
kw
=
movement_diff
.
getMovementPropertyDict
(
movement
)
for
movement
,
kw
in
movement_diff
.
getUpdatableMovementList
():
movement
.
edit
(
**
kw
)
for
property_id
in
kw
.
iterkeys
()
:
for
property_id
in
kw
:
movement
.
clearRecordedProperty
(
property_id
)
for
movement
in
movement_diff
.
getNewMovementList
():
kw
=
movement_diff
.
getMovementPropertyDict
(
movement
)
movement
=
context
.
newContent
(
portal_type
=
self
.
movement_type
,
**
kw
)
d
=
movement
.
__dict__
# make sure our optimization does not touch existing persistent data
assert
movement
.
isTempObject
()
and
'_original'
not
in
d
del
movement
.
__dict__
movement
=
context
.
newContent
(
portal_type
=
self
.
movement_type
)
d
.
update
(
movement
.
__dict__
)
movement
.
__dict__
=
d
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