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
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
Show 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 @@
...
@@ -26,6 +26,7 @@
from
Shared.DC.ZRDB.TM
import
TM
from
Shared.DC.ZRDB.TM
import
TM
from
zLOG
import
LOG
,
ERROR
,
INFO
from
zLOG
import
LOG
,
ERROR
,
INFO
import
sys
import
sys
from
collections
import
defaultdict
import
transaction
import
transaction
...
@@ -35,8 +36,8 @@ class ActivityBuffer(TM):
...
@@ -35,8 +36,8 @@ class ActivityBuffer(TM):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
queued_activity
=
[]
self
.
queued_activity
=
[]
self
.
message_list_dict
=
{}
self
.
message_list_dict
=
defaultdict
(
list
)
self
.
uid_set_dict
=
{}
self
.
uid_set_dict
=
defaultdict
(
set
)
def
_clear
(
self
):
def
_clear
(
self
):
del
self
.
queued_activity
[:]
del
self
.
queued_activity
[:]
...
@@ -45,10 +46,10 @@ class ActivityBuffer(TM):
...
@@ -45,10 +46,10 @@ class ActivityBuffer(TM):
self
.
activity_tool
=
None
self
.
activity_tool
=
None
def
getMessageList
(
self
,
activity
):
def
getMessageList
(
self
,
activity
):
return
self
.
message_list_dict
.
setdefault
(
activity
,
[])
return
self
.
message_list_dict
[
activity
]
def
getUidSet
(
self
,
activity
):
def
getUidSet
(
self
,
activity
):
return
self
.
uid_set_dict
.
setdefault
(
activity
,
set
())
return
self
.
uid_set_dict
[
activity
]
def
_register
(
self
,
activity_tool
):
def
_register
(
self
,
activity_tool
):
if
not
self
.
_registered
:
if
not
self
.
_registered
:
...
@@ -65,9 +66,9 @@ class ActivityBuffer(TM):
...
@@ -65,9 +66,9 @@ class ActivityBuffer(TM):
try
:
try
:
activity_tool
=
self
.
activity_tool
activity_tool
=
self
.
activity_tool
# Try to push all messages
# Try to push all messages
activity_dict
=
{}
activity_dict
=
defaultdict
(
list
)
for
activity
,
message
in
self
.
queued_activity
[
queued
:]:
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
():
for
activity
,
message_list
in
activity_dict
.
iteritems
():
activity
.
prepareQueueMessageList
(
activity_tool
,
message_list
)
activity
.
prepareQueueMessageList
(
activity_tool
,
message_list
)
self
.
_prepare_args
=
len
(
self
.
queued_activity
),
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