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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
erp5
Commits
05a7bebe
Commit
05a7bebe
authored
Jun 10, 2015
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Catalog: fixed parameter propagation when using searchAndActivate and grouping
parent
fef6cdfb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
product/ERP5Catalog/CatalogTool.py
product/ERP5Catalog/CatalogTool.py
+2
-1
product/ERP5Catalog/tests/testERP5Catalog.py
product/ERP5Catalog/tests/testERP5Catalog.py
+45
-0
No files found.
product/ERP5Catalog/CatalogTool.py
View file @
05a7bebe
...
...
@@ -1031,7 +1031,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
next_kw
[
'priority'
]
=
1
+
next_kw
.
get
(
'priority'
,
1
)
self
.
activate
(
activity
=
'SQLQueue'
,
**
next_kw
)
\
.
_searchAndActivate
(
method_id
,
method_args
,
method_kw
,
activate_kw
,
r
[
-
1
].
getUid
(),
**
kw
)
activate_kw
,
r
[
-
1
].
getUid
(),
group_kw
=
group_kw
,
**
kw
)
if
select_method_id
:
portal_activities
=
self
.
getPortalObject
().
portal_activities
active_portal_activities
=
portal_activities
.
activate
(
...
...
product/ERP5Catalog/tests/testERP5Catalog.py
View file @
05a7bebe
...
...
@@ -4059,6 +4059,51 @@ VALUES
self
.
assertEqual
([
x
.
getObject
()
for
x
in
catalog
.
searchResults
(
**
query_lj
)],
[
org_a
.
default_address
])
def
testSearchAndActivateWithGroupMethodId
(
self
):
"""
Make sure searchAndActivate method could be used with a grouping method,
and in particular make sure sure searchAndActivate can calls himself
properly.
We create 300 organisations and use a group method cost of 0.5.
So this means searchAndActivate should first create 200 activities
that will be grouped by 2. Then searchAndActivate will call himself
another time to activate the last 100 organisations, and in their turn
they will be grouped by 2.
"""
group_method_call_list
=
[]
def
doSomething
(
self
,
message_list
):
r
=
[]
for
m
in
message_list
:
m
.
result
=
r
.
append
(
m
.
object
.
getPath
())
r
.
sort
()
group_method_call_list
.
append
(
r
)
self
.
portal
.
portal_activities
.
__class__
.
doSomething
=
doSomething
now
=
DateTime
()
try
:
organisation_list
=
[]
for
x
in
xrange
(
0
,
300
):
organisation_list
.
append
(
self
.
portal
.
organisation_module
.
newContent
().
getPath
())
self
.
tic
()
self
.
portal
.
portal_catalog
.
searchAndActivate
(
creation_date
=
{
'query'
:
now
,
'range'
:
'min'
},
method_id
=
"dummyDoSomething"
,
group_kw
=
{
"group_method_id"
:
"portal_activities/doSomething"
,
"group_method_cost"
:
0.5
},
)
self
.
tic
()
self
.
assertEqual
(
150
,
len
(
group_method_call_list
))
organisation_call_list
=
[]
for
call_path_list
in
group_method_call_list
:
self
.
assertEqual
(
2
,
len
(
call_path_list
))
organisation_call_list
.
extend
(
call_path_list
)
organisation_call_list
.
sort
()
organisation_list
.
sort
()
self
.
assertEqual
(
organisation_call_list
,
organisation_list
)
finally
:
del
self
.
portal
.
portal_activities
.
__class__
.
doSomething
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestERP5Catalog
))
...
...
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