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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aaron Chen
erp5
Commits
f4d9e615
Commit
f4d9e615
authored
Aug 14, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFActivity.ActivityBuffer: Switch to defaultdict.
parent
8925e816
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
product/CMFActivity/ActivityBuffer.py
product/CMFActivity/ActivityBuffer.py
+7
-6
No files found.
product/CMFActivity/ActivityBuffer.py
View file @
f4d9e615
...
...
@@ -26,6 +26,7 @@
from
Shared.DC.ZRDB.TM
import
TM
from
zLOG
import
LOG
,
ERROR
,
INFO
import
sys
from
collections
import
defaultdict
import
transaction
...
...
@@ -35,8 +36,8 @@ class ActivityBuffer(TM):
def
__init__
(
self
):
self
.
queued_activity
=
[]
self
.
message_list_dict
=
{}
self
.
uid_set_dict
=
{}
self
.
message_list_dict
=
defaultdict
(
list
)
self
.
uid_set_dict
=
defaultdict
(
set
)
def
_clear
(
self
):
del
self
.
queued_activity
[:]
...
...
@@ -45,10 +46,10 @@ class ActivityBuffer(TM):
self
.
activity_tool
=
None
def
getMessageList
(
self
,
activity
):
return
self
.
message_list_dict
.
setdefault
(
activity
,
[])
return
self
.
message_list_dict
[
activity
]
def
getUidSet
(
self
,
activity
):
return
self
.
uid_set_dict
.
setdefault
(
activity
,
set
())
return
self
.
uid_set_dict
[
activity
]
def
_register
(
self
,
activity_tool
):
if
not
self
.
_registered
:
...
...
@@ -65,9 +66,9 @@ class ActivityBuffer(TM):
try
:
activity_tool
=
self
.
activity_tool
# Try to push all messages
activity_dict
=
{}
activity_dict
=
defaultdict
(
list
)
for
activity
,
message
in
self
.
queued_activity
[
queued
:]:
activity_dict
.
setdefault
(
activity
,
[])
.
append
(
message
)
activity_dict
[
activity
]
.
append
(
message
)
for
activity
,
message_list
in
activity_dict
.
iteritems
():
activity
.
prepareQueueMessageList
(
activity_tool
,
message_list
)
self
.
_prepare_args
=
len
(
self
.
queued_activity
),
...
...
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