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
beb29b94
Commit
beb29b94
authored
Jul 05, 2013
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
if we do no split indexation, do no create an activity for it, run it
parent
9b4d79c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
39 deletions
+44
-39
product/ERP5SyncML/Document/SyncMLSubscription.py
product/ERP5SyncML/Document/SyncMLSubscription.py
+44
-39
No files found.
product/ERP5SyncML/Document/SyncMLSubscription.py
View file @
beb29b94
...
@@ -132,47 +132,54 @@ class SyncMLSubscription(XMLObject):
...
@@ -132,47 +132,54 @@ class SyncMLSubscription(XMLObject):
r
=
self
.
getDocumentList
()
# It is assumed that
r
=
self
.
getDocumentList
()
# It is assumed that
# the result is sorted
# the result is sorted
result_count
=
len
(
r
)
result_count
=
len
(
r
)
generated_other_activity
=
False
if
result_count
:
if
result_count
:
# XXX If not split, call the callback here, no need of activity
r
=
[
x
.
path
for
x
in
r
]
syncml_logger
.
info
(
"getAndIndex : got %d, %r result, limit = %r, packet %r"
%
if
not
limit
:
(
result_count
,
r
,
limit
,
packet_size
))
# We do not split in activity so call the callback right now
if
result_count
==
limit
:
syncml_logger
.
info
(
"getAndIndex : got %d, %r result and no limit, calling callback..."
%
# Recursive call to prevent too many activity generation
(
result_count
,
r
))
next_kw
=
dict
(
activate_kw
,
priority
=
1
+
activate_kw
.
get
(
'priority'
,
1
))
callback_method
=
getattr
(
self
,
callback
)
kw
[
"min_id"
]
=
r
[
-
1
].
getId
()
callback_method
(
path_list
=
r
[:],
syncml_logger
.
info
(
"--> calling getAndActivate in activity, min = %s"
%
activate_kw
=
activate_kw
,
(
kw
[
"min_id"
],))
**
method_kw
)
self
.
activate
(
**
next_kw
).
getAndActivate
(
callback
,
method_kw
,
activate_kw
,
**
kw
)
generated_other_activity
=
True
r
=
[
x
.
getPath
()
for
x
in
r
]
activate
=
self
.
getPortalObject
().
portal_synchronizations
.
activate
callback_method
=
getattr
(
activate
(
**
activate_kw
),
callback
)
if
generated_other_activity
:
for
i
in
xrange
(
0
,
result_count
,
packet_size
):
syncml_logger
.
info
(
"-- getAndIndex : recursive call, generating for %s"
%
(
r
[
i
:
i
+
packet_size
],))
callback_method
(
path_list
=
r
[
i
:
i
+
packet_size
],
activate_kw
=
activate_kw
,
**
method_kw
)
else
:
else
:
if
result_count
>
packet_size
and
limit
:
syncml_logger
.
info
(
"getAndIndex : got %d, %r result, limit = %r, packet %r"
%
for
i
in
xrange
(
0
,
result_count
-
packet_size
,
packet_size
):
(
result_count
,
r
,
limit
,
packet_size
))
syncml_logger
.
info
(
"-- getAndIndex : i %s, call, generating for %s : %s"
%
generated_other_activity
=
False
(
i
,
r
[
i
:
i
+
packet_size
],
activate_kw
))
if
result_count
==
limit
:
# Recursive call to prevent too many activity generation
next_kw
=
dict
(
activate_kw
,
priority
=
1
+
activate_kw
.
get
(
'priority'
,
1
))
kw
[
"min_id"
]
=
r
[
-
1
].
getId
()
syncml_logger
.
info
(
"--> calling getAndIndex in activity, min = %s"
%
(
kw
[
"min_id"
],))
self
.
activate
(
**
next_kw
).
getAndIndex
(
callback
,
method_kw
,
activate_kw
,
**
kw
)
generated_other_activity
=
True
activate
=
self
.
activate
callback_method
=
getattr
(
activate
(
**
activate_kw
),
callback
)
if
generated_other_activity
:
for
i
in
xrange
(
0
,
result_count
,
packet_size
):
syncml_logger
.
info
(
"-- getAndIndex : recursive call, generating for %s"
%
(
r
[
i
:
i
+
packet_size
],))
callback_method
(
path_list
=
r
[
i
:
i
+
packet_size
],
callback_method
(
path_list
=
r
[
i
:
i
+
packet_size
],
activate_kw
=
activate_kw
,
**
method_kw
)
**
method_kw
)
final_min
=
i
+
packet_size
else
:
else
:
final_min
=
0
if
result_count
>
packet_size
and
limit
:
syncml_logger
.
info
(
"---- getAndIndex : final call for %s %s : %s"
\
for
i
in
xrange
(
0
,
result_count
-
packet_size
,
packet_size
):
%
(
final_min
,
r
[
final_min
:],
activate_kw
))
syncml_logger
.
info
(
"-- getAndIndex : i %s, call, generating for %s : %s"
%
callback_method
(
path_list
=
r
[
final_min
:],
(
i
,
r
[
i
:
i
+
packet_size
],
activate_kw
))
activate_kw
=
activate_kw
,
callback_method
(
path_list
=
r
[
i
:
i
+
packet_size
],
**
method_kw
)
**
method_kw
)
final_min
=
i
+
packet_size
else
:
final_min
=
0
syncml_logger
.
info
(
"---- getAndIndex : final call for %s %s : %s"
\
%
(
final_min
,
r
[
final_min
:],
activate_kw
))
callback_method
(
path_list
=
r
[
final_min
:],
activate_kw
=
activate_kw
,
**
method_kw
)
return
result_count
return
result_count
security
.
declarePrivate
(
'generateBaseResponse'
)
security
.
declarePrivate
(
'generateBaseResponse'
)
...
@@ -296,8 +303,7 @@ class SyncMLSubscription(XMLObject):
...
@@ -296,8 +303,7 @@ class SyncMLSubscription(XMLObject):
message_id_list = self.getNextMessageIdList(id_count=result_count)
message_id_list = self.getNextMessageIdList(id_count=result_count)
# XXX maybe (result_count / packet_size) + 1 instead of result_count
# XXX maybe (result_count / packet_size) + 1 instead of result_count
message_id_list.reverse() # We pop each id in the following loop
message_id_list.reverse() # We pop each id in the following loop
activate = self.activate
callback_method = getattr(self.activate(**activate_kw), callback)
callback_method = getattr(activate(**activate_kw), callback)
if generated_other_activity:
if generated_other_activity:
# XXX Can be factorized with following code
# XXX Can be factorized with following code
# upper_limit of xrange + some check ???
# upper_limit of xrange + some check ???
...
@@ -453,7 +459,6 @@ class SyncMLSubscription(XMLObject):
...
@@ -453,7 +459,6 @@ class SyncMLSubscription(XMLObject):
# XXX Some improvement can also be done to retrieve a list of document at once
# XXX Some improvement can also be done to retrieve a list of document at once
# Get the data
# Get the data
syncml_logger.info("
applySync
:
got
data
%
r" %(action["
raw_data
"],))
if 'xml_data' in action:
if 'xml_data' in action:
# Rebuild an Element
# Rebuild an Element
incoming_data = etree.fromstring(action["
xml_data
"])
incoming_data = etree.fromstring(action["
xml_data
"])
...
...
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