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
f1d0f4da
Commit
f1d0f4da
authored
Jul 01, 2013
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless access to document in _getSyncMLData as data is now retrieved from sql table
parent
76113390
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
188 additions
and
195 deletions
+188
-195
product/ERP5SyncML/Document/SyncMLSubscription.py
product/ERP5SyncML/Document/SyncMLSubscription.py
+188
-195
No files found.
product/ERP5SyncML/Document/SyncMLSubscription.py
View file @
f1d0f4da
...
...
@@ -704,10 +704,12 @@ class SyncMLSubscription(XMLObject):
if portal.portal_preferences.getPreferredCheckDeleteAtEnd() is False:
raise NotImplementedError
object_list =
[traverse(x.path) for x in
self.z_get_syncml_path_list(
object_list = self.z_get_syncml_path_list(
min_gid=min_gid,
max_gid=max_gid,
path=self.getSearchableSourcePath())]
path=self.getSearchableSourcePath())
syncml_logger.info("
getSyncMLData
,
object
list
is
%
s
" % ([x.path for x in object_list]))
alert_code = self.getSyncmlAlertCode()
sync_all = alert_code in ("
refresh_from_client_only
", "
slow_sync
")
...
...
@@ -721,48 +723,34 @@ class SyncMLSubscription(XMLObject):
path_list = []
for result in object_list:
object_path = result.getPath()
# if loop >= max_range:
# # For now, maximum object list is always none, so we will never come here !
# syncml_logger.warning("
...
Send
too
many
objects
,
will
split
message
...
")
# finished = False
# break
# Get the GID
document = traverse(object_path)
gid = self.getGidFromObject(document)
if not gid:
raise ValueError("
Impossible
to
compute
gid
for
%
s
" %(object_path))
if True: # not loop: # or len(syncml_response) < MAX_LEN:
document_path = result.path
gid = result.gid
document_data = result.data
# XXX must find a better way to prevent sending
# no object due to a too small limit
signature = self.getSignatureFromGid(gid)
more_data = False
if signature:
syncml_logger.debug
("
signature
is
%
s
=
%
s
" %(signature.getRelativeUrl(),
syncml_logger.info
("
signature
is
%
s
=
%
s
" %(signature.getRelativeUrl(),
signature.getValidationState()))
# For the case it was never synchronized, we have to send everything
if not signature or sync_all:
# Either it is the first time we get this object
# either the synchronization process required
# to send every data again as if it was never done before
document_data = conduit.getXMLFromObjectWithId(
# XXX To be renamed (getDocumentData) independant from format
document,
xml_mapping=self.getXmlBindingGeneratorMethodId(),
context_document=self.getPath())
if not document_data:
# XXX Which case leads here ?
raise ValueError("
No
data
for
%
s
/
%
s
" %(gid, document_path))
continue
if create_signature:
if not signature:
signature = self.newContent(portal_type='SyncML Signature',
id=gid,
reference=document.getPath()
,
reference=document_path
,
temporary_data=document_data)
syncml_logger.debug
("
Created
a
signature
%
s
for
gid
=
%
s
,
path
%
s
"
% (signature.getPath(), gid, document.getPath()
))
syncml_logger.info
("
Created
a
signature
%
s
for
gid
=
%
s
,
path
%
s
"
% (signature.getPath(), gid, document_path
))
if len(document_data) > MAX_LEN:
syncml_logger.info("
data
too
big
,
sending
multiple
message
")
more_data = True
...
...
@@ -777,7 +765,7 @@ class SyncMLSubscription(XMLObject):
# confirmation that the document was well synchronized
signature.setTemporaryData(document_data)
signature.doSync()
syncml_logger.debug
("
signature
%
s
is
syncing
"
syncml_logger.info
("
signature
%
s
is
syncing
"
% (signature.getRelativeUrl(),))
# Generate the message
...
...
@@ -791,10 +779,6 @@ class SyncMLSubscription(XMLObject):
elif signature.getValidationState() in ('not_synchronized', 'synchronized',
'conflict_resolved_with_merge'):
# We don't have synchronized this object yet but it has a signature
xml_object = conduit.getXMLFromObjectWithId(document,
xml_mapping=self.getXmlBindingGeneratorMethodId(),
context_document=self.getPath())
if signature.getValidationState() == 'conflict_resolved_with_merge':
# XXX Why putting confirmation message here
# Server can get confirmation of sync although it has not yet
...
...
@@ -804,17 +788,17 @@ class SyncMLSubscription(XMLObject):
source_ref=signature.getId(),
sync_code='conflict_resolved_with_merge',
command='Replace')
syncml_logger.debug("
\
tMD5
is
%
s
for
%
s
" %((signature.checkMD5(xml_object
)),
syncml_logger.info("
\
tMD5
is
%
s
for
%
s
" %((signature.checkMD5(document_data
)),
signature.getReference()))
if not signature.checkMD5(xml_object
):
if not signature.checkMD5(document_data
):
# MD5 checksum tell there is a modification of the object
if conduit.getContentType() != 'text/xml':
# If there is no xml, we re-send the whole object
# XXX this must be managed by conduit ?
data_diff = xml_object
data_diff = document_data
else:
# Compute the diff
new_document = conduit.replaceIdFromXML(xml_object
, 'gid', gid)
new_document = conduit.replaceIdFromXML(document_data
, 'gid', gid)
previous_document = conduit.replaceIdFromXML(signature.getData(),
'gid', gid)
data_diff = conduit.generateDiff(new_data=new_document,
...
...
@@ -847,7 +831,7 @@ class SyncMLSubscription(XMLObject):
# Store the new representation of the document
# It will be copy to "
data
" property once synchronization
# is confirmed
signature.setTemporaryData(xml_object
)
signature.setTemporaryData(document_data
)
signature.doSync()
syncml_logger.debug("
signature
%
s
is
syncing
"
% (signature.getRelativeUrl(),))
...
...
@@ -878,7 +862,7 @@ class SyncMLSubscription(XMLObject):
previous_xml_with_gid = conduit.replaceIdFromXML(signature.getData(),
'gid', gid,
as_string=False)
conduit.updateNode(xml=xml_update, object=document
,
conduit.updateNode(xml=xml_update, object=traverse(document_path)
,
previous_xml=previous_xml_with_gid, force=True,
gid=gid,
signature=signature,
...
...
@@ -927,9 +911,6 @@ class SyncMLSubscription(XMLObject):
else:
syncml_logger.info("
Splitting
document
")
break
else:
syncml_logger.warning("
Package
is
going
to
be
splitted
")
break
self.SQLCatalog_indexSyncMLDocumentList(path_list)
syncml_logger.info("
_getSyncMLData
end
with
finished
%
s
"
...
...
@@ -969,6 +950,18 @@ class SyncMLSubscription(XMLObject):
else:
return self._baseGetXmlBindingGeneratorMethodId(default=default)
security.declareProtected(Permissions.AccessContentsInformation,
'getDataFromDocument')
def getDataFromDocument(self, document):
"""
Return the data (xml or other) for a given document
"""
return self.getConduit().getXMLFromObjectWithId(
document,
xml_mapping=self.getXmlBindingGeneratorMethodId(),
context_document=self.getPath())
security.declareProtected(Permissions.AccessContentsInformation,
'getGidFromObject')
def getGidFromObject(self, object, encoded=True):
...
...
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