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
Hamza
erp5
Commits
264111e7
Commit
264111e7
authored
Jul 01, 2013
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sendSyncCommand can be defined directly on subscription
parent
566f0498
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
39 deletions
+34
-39
product/ERP5SyncML/Document/SyncMLSubscription.py
product/ERP5SyncML/Document/SyncMLSubscription.py
+33
-6
product/ERP5SyncML/Engine/SynchronousEngine.py
product/ERP5SyncML/Engine/SynchronousEngine.py
+1
-0
product/ERP5SyncML/Tool/SynchronizationTool.py
product/ERP5SyncML/Tool/SynchronizationTool.py
+0
-33
No files found.
product/ERP5SyncML/Document/SyncMLSubscription.py
View file @
264111e7
...
@@ -176,14 +176,41 @@ class SyncMLSubscription(XMLObject):
...
@@ -176,14 +176,41 @@ class SyncMLSubscription(XMLObject):
"""
"""
return
"%s%%"
%
(
self
.
getSourceValue
().
getPath
().
replace
(
"_"
,
"
\
_
"
),)
return
"%s%%"
%
(
self
.
getSourceValue
().
getPath
().
replace
(
"_"
,
"
\
_
"
),)
def sendSyncCommand(self, min_gid, max_gid, message_id, activate_kw):
"""
This methods is intented to be called by asynchronous engine in activity to
send sync commands for a subset of data
"""
# Build Message
syncml_response = SyncMLResponse()
# XXX Make a generic method that already exists in engines
syncml_response.addHeader(
session_id=self.getSessionId(),
message_id=message_id,
target=self.getUrlString(),
source=self.getSubscriptionUrlString())
syncml_response.addBody()
self._getSyncMLData(
syncml_response=syncml_response,
min_gid=min_gid,
max_gid=max_gid,
)
# Send the message in activity to prevent recomputation of data in case of
# transport failure
# activate_kw["
group_method_id
"] = None
# activate_kw["
group_method_cost
"] = .05
self.activate(**activate_kw).sendMessage(xml=str(syncml_response))
security.declarePrivate('getAndActivate')
security.declarePrivate('getAndActivate')
def getAndActivate(self, callback,
method_kw,
activate_kw, **kw):
def getAndActivate(self, callback, activate_kw, **kw):
"""
"""
This methods is called by the asynchronous engine to split activity
This methods is called by the asynchronous engine to split activity
generation into activities.
generation into activities.
callback : method to call in activity
callback : method to call in activity
method_kw : callback's parameters
activate_kw : activity parameters to pass to activate call
activate_kw : activity parameters to pass to activate call
kw : any parameter getAndActivate can required if it calls itself
kw : any parameter getAndActivate can required if it calls itself
...
@@ -223,13 +250,13 @@ class SyncMLSubscription(XMLObject):
...
@@ -223,13 +250,13 @@ class SyncMLSubscription(XMLObject):
syncml_logger.info("
-->
calling
getAndActivate
in
activity
,
min
=
%
s
" %
syncml_logger.info("
-->
calling
getAndActivate
in
activity
,
min
=
%
s
" %
(kw["
min_gid
"],))
(kw["
min_gid
"],))
self.activate(**next_kw).getAndActivate(
self.activate(**next_kw).getAndActivate(
callback,
method_kw,
activate_kw, **kw)
callback, activate_kw, **kw)
generated_other_activity = True
generated_other_activity = True
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.
getPortalObject().portal_synchronizations.
activate
activate = self.activate
callback_method = getattr(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
...
@@ -496,8 +523,8 @@ class SyncMLSubscription(XMLObject):
...
@@ -496,8 +523,8 @@ class SyncMLSubscription(XMLObject):
elif action['command'] == 'Delete':
elif action['command'] == 'Delete':
status_code="
success
"
status_code="
success
"
document = self.getDocumentFromGid(signature.getId())
document = self.getDocumentFromGid(signature.getId())
syncml_logger.info("
Deleting
signature
%
s
&
doc
%
s
" %(signature.getPath(),
#
syncml_logger.info("
Deleting
signature
%
s
&
doc
%
s
" %(signature.getPath(),
document.getPath()))
#
document.getPath()))
path_list.remove(signature.getPath())
path_list.remove(signature.getPath())
if document is not None:
if document is not None:
# XXX Can't we get conflict ?
# XXX Can't we get conflict ?
...
...
product/ERP5SyncML/Engine/SynchronousEngine.py
View file @
264111e7
...
@@ -149,6 +149,7 @@ class SyncMLSynchronousEngine(EngineMixin):
...
@@ -149,6 +149,7 @@ class SyncMLSynchronousEngine(EngineMixin):
raise
ValueError
(
"Authentication failed, impossible to sync data"
)
raise
ValueError
(
"Authentication failed, impossible to sync data"
)
# Apply command & send modifications
# Apply command & send modifications
# XXX This can be called on subscription instead
syncml_response
=
self
.
_generateBaseResponse
(
subscriber
)
syncml_response
=
self
.
_generateBaseResponse
(
subscriber
)
# Apply status about object send & synchronized if any
# Apply status about object send & synchronized if any
...
...
product/ERP5SyncML/Tool/SynchronizationTool.py
View file @
264111e7
...
@@ -440,37 +440,4 @@ class SynchronizationTool(BaseTool):
...
@@ -440,37 +440,4 @@ class SynchronizationTool(BaseTool):
tag
=
activate_kw
).
sendMessage
(
xml
=
str
(
syncml_response
))
tag
=
activate_kw
).
sendMessage
(
xml
=
str
(
syncml_response
))
def
sendSyncCommand
(
self
,
gid_list
,
message_id
,
subscription_path
,
activate_kw
,
first_call
=
False
,
last_call
=
False
):
"""
This methods is intented to be called by asynchronous engine in activity to
send sync commands for a subset of data
"""
subscription
=
self
.
restrictedTraverse
(
subscription_path
)
assert
subscription
is
not
None
,
"Impossible to find subscription %s"
\
%
(
subscription_path
)
# Build Message
syncml_response
=
SyncMLResponse
()
syncml_response
.
addHeader
(
session_id
=
subscription
.
getSessionId
(),
message_id
=
message_id
,
target
=
subscription
.
getUrlString
(),
source
=
subscription
.
getSubscriptionUrlString
())
syncml_response
.
addBody
()
subscription
.
_getSyncMLData
(
syncml_response
=
syncml_response
,
gid_list
=
gid_list
,
first_call
=
first_call
,
last_call
=
last_call
,
)
# Send the message in activity to prevent recomputation of data in case of
# transport failure
# activate_kw["group_method_id"] = None
# activate_kw["group_method_cost"] = .05
subscription
.
activate
(
**
activate_kw
).
sendMessage
(
xml
=
str
(
syncml_response
))
InitializeClass
(
SynchronizationTool
)
InitializeClass
(
SynchronizationTool
)
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