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
Eteri
erp5
Commits
0f6857b1
Commit
0f6857b1
authored
Mar 07, 2013
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup SyncML Signature class
remove useless commented code improve method comments
parent
67230753
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
84 deletions
+39
-84
product/ERP5SyncML/Document/SyncMLSignature.py
product/ERP5SyncML/Document/SyncMLSignature.py
+39
-84
No files found.
product/ERP5SyncML/Document/SyncMLSignature.py
View file @
0f6857b1
...
...
@@ -41,20 +41,17 @@ _MARKER = []
class
SyncMLSignature
(
XMLObject
):
"""
status -- SENT, CONFLICT...
md5_object -- An MD5 value of a given document
#uid -- The UID of the document
id -- the ID of the document
gid -- the global id of the document
rid -- the uid of the document on the remote database,
only needed on the server.
xml -- the xml of the object at the time where it was synchronized
A Signature represent a document that is synchronized
It contains as attribute the xml representation of the object which is used
to generate the diff of the object between two synchronization
It also contains the list of conflict as sub-objects when it happens
"""
meta_type
=
'ERP5 Signature'
portal_type
=
'SyncML Signature'
isIndexable
=
ConstantGetter
(
'isIndexable'
,
value
=
False
)
# Make sure RAD generated accessors at the class level
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
...
...
@@ -72,12 +69,11 @@ class SyncMLSignature(XMLObject):
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setData'
)
def
setData
(
self
,
value
):
"""
s
et the XML corresponding to the object
S
et the XML corresponding to the object
"""
if
value
:
# convert the string to Pdata
pdata_wrapper
=
PdataHelper
(
self
.
getPortalObject
(),
value
)
#data, size = pdata_wrapper()
self
.
_setData
(
pdata_wrapper
)
self
.
setTemporaryData
(
None
)
# We make sure that the data will not be erased
self
.
setContentMd5
(
pdata_wrapper
.
getContentMd5
())
...
...
@@ -88,7 +84,7 @@ class SyncMLSignature(XMLObject):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getData'
)
def
getData
(
self
,
default
=
_MARKER
):
"""
g
et the XML corresponding to the object
G
et the XML corresponding to the object
"""
if
self
.
hasData
():
return
str
(
self
.
_baseGetData
())
...
...
@@ -114,7 +110,7 @@ class SyncMLSignature(XMLObject):
'getTemporaryData'
)
def
getTemporaryData
(
self
,
default
=
_MARKER
):
"""
get the temp xml
Return the temp xml as string
"""
if
self
.
hasTemporaryData
():
return
str
(
self
.
_baseGetTemporaryData
())
...
...
@@ -126,9 +122,9 @@ class SyncMLSignature(XMLObject):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'checkMD5'
)
def
checkMD5
(
self
,
xml_string
):
"""
check if the given md5_object returns the same things as
th
e one stored in this signature, this is very usefull
if we want to know if an objects has
changed or not
Check if the given md5_object returns the same things as the one stored in
th
is signature, this is very usefull if we want to know if an objects has
changed or not
Returns 1 if MD5 are equals, else it returns 0
"""
if
isinstance
(
xml_string
,
unicode
):
...
...
@@ -138,8 +134,7 @@ class SyncMLSignature(XMLObject):
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setPartialData'
)
def
setPartialData
(
self
,
value
):
"""
Set the partial string we will have to
deliver in the future
Set the partial string we will have to deliver in the future
"""
if
value
:
if
not
isinstance
(
value
,
PdataHelper
):
...
...
@@ -153,9 +148,8 @@ class SyncMLSignature(XMLObject):
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setLastData'
)
def
setLastData
(
self
,
value
):
"""
This is the xml temporarily saved, it will
be stored with setXML when we will receive
the confirmation of synchronization
This is the xml temporarily saved, it will be stored with setXML when we
will receive the confirmation of synchronization
"""
if
value
:
self
.
_setLastData
(
PdataHelper
(
self
.
getPortalObject
(),
value
))
...
...
@@ -166,7 +160,7 @@ class SyncMLSignature(XMLObject):
'getPartialData'
)
def
getPartialData
(
self
,
default
=
_MARKER
):
"""
get the patial xml
Return the patial xml as string
"""
if
self
.
hasPartialData
():
return
str
(
self
.
_baseGetPartialData
())
...
...
@@ -175,7 +169,8 @@ class SyncMLSignature(XMLObject):
else
:
return
self
.
_baseGetPartialData
(
default
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'appendPartialData'
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'appendPartialData'
)
def
appendPartialData
(
self
,
value
):
"""
Append the partial string we will have to deliver in the future
...
...
@@ -192,36 +187,11 @@ class SyncMLSignature(XMLObject):
self
.
setPartialData
(
value
)
self
.
setLastDataPartialData
(
last_data
)
#security.declareProtected(Permissions.AccessContentsInformation,
#'getFirstChunkPdata')
#def getFirstChunkPdata(self, size_lines):
#"""
#"""
#chunk = [self.getPartialData().data]
#size = chunk[0].count('\n')
#current = self.getPartialData()
#next = current.next
#while size < size_lines and next is not None:
#current = next
#size += current.data.count('\n')
#chunk.append(current.data)
#next = current.next
#if size == size_lines:
#self.setPartialData(next)
#elif size > size_lines:
#overflow = size - size_lines
#data_list = chunk[-1].split('\n')
#chunk[-1] = '\n'.join(data_list[:-overflow])
#current.data = '\n'.join(data_list[-overflow:])
#self.setPartialData(current)
#return ''.join(chunk)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'getFirstPdataChunk'
)
def
getFirstPdataChunk
(
self
,
max_len
):
"""
"""
#chunk, rest_in_queue = self._baseGetPartialData().\
#getFirstPdataChunkAndRestInQueue(max_len)
partial_data
=
self
.
_baseGetPartialData
()
chunk
=
partial_data
[:
max_len
]
rest_in_queue
=
partial_data
[
max_len
:]
...
...
@@ -233,9 +203,8 @@ class SyncMLSignature(XMLObject):
'setSubscriberXupdate'
)
def
setSubscriberXupdate
(
self
,
value
):
"""
This is the xml temporarily saved, it will
be stored with setXML when we will receive
the confirmation of synchronization
This is the xml temporarily saved, it will be stored with setXML when we
will receive the confirmation of synchronization
"""
if
value
:
self
.
_setSubscriberXupdate
(
PdataHelper
(
self
.
getPortalObject
(),
value
))
...
...
@@ -246,7 +215,7 @@ class SyncMLSignature(XMLObject):
'getSubscriberXupdate'
)
def
getSubscriberXupdate
(
self
,
default
=
_MARKER
):
"""
get the patial xml
Return the patial xml as string
"""
if
self
.
hasSubscriberXupdate
():
return
str
(
self
.
_baseGetSubscriberXupdate
())
...
...
@@ -259,9 +228,8 @@ class SyncMLSignature(XMLObject):
'setPublisherXupdate'
)
def
setPublisherXupdate
(
self
,
value
):
"""
This is the xml temporarily saved, it will
be stored with setXML when we will receive
the confirmation of synchronization
This is the xml temporarily saved, it will be stored with setXML when we
will receive the confirmation of synchronization
"""
if
value
:
self
.
_setPublisherXupdate
(
PdataHelper
(
self
.
getPortalObject
(),
value
))
...
...
@@ -272,7 +240,7 @@ class SyncMLSignature(XMLObject):
'getPublisherXupdate'
)
def
getPublisherXupdate
(
self
,
default
=
_MARKER
):
"""
get the patial xml
Return the partial xml as string
"""
if
self
.
hasPublisherXupdate
():
return
str
(
self
.
_baseGetPublisherXupdate
())
...
...
@@ -281,7 +249,6 @@ class SyncMLSignature(XMLObject):
else
:
return
self
.
_baseGetPublisherXupdate
(
default
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'reset'
)
def
reset
(
self
,
no_conflict
=
False
):
...
...
@@ -300,46 +267,34 @@ class SyncMLSignature(XMLObject):
if
self
.
getValidationState
()
!=
'not_synchronized'
:
self
.
drift
()
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'getConflictList'
)
def
getConflictList
(
self
):
"""
Return the actual action for a partial synchronization
"""
return
self
.
contentValues
()
# returned_conflict_list = []
# if getattr(self, 'conflict_list', None) is None:
# return returned_conflict_list
# if len(self.conflict_list)>0:
# returned_conflict_list.extend(self.conflict_list)
# return returned_conflict_list
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setConflictList'
)
def
setConflictList
(
self
,
conflict_list
):
"""
Return the actual action for a partial synchronization
XXX is it still usefull ?
"""
return
# if conflict_list is None or conflict_list == []:
# self.resetConflictList()
# else:
# self.conflict_list = conflict_list
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'resetConflictList'
)
def
resetConflictList
(
self
):
"""
Return the actual action for a partial synchronization
XXX is it still usefull ?
"""
return
#self.conflict_list = PersistentMapping()
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'delConflict'
)
def
delConflict
(
self
,
conflict
):
"""
Delete provided conflict object
"""
self
.
manage_delObjects
([
conflict
.
getId
(),])
# conflict_list = []
# for c in self.getConflictList():
# #LOG('delConflict, c==conflict',0,c==aq_base(conflict))
# if c != aq_base(conflict):
# conflict_list += [c]
# if conflict_list != []:
# self.setConflictList(conflict_list)
# else:
# self.resetConflictList()
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