Remove "self" in interfaces/conduit, correction of the English and coding style


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28255 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 326ba859
...@@ -481,7 +481,6 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -481,7 +481,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
This will change the xml in order to change the update This will change the xml in order to change the update
from the object to the subobject from the object to the subobject
""" """
# XXX sometimes problems not resolve
from copy import deepcopy from copy import deepcopy
xml_copy = deepcopy(xml) xml_copy = deepcopy(xml)
self.changeSubObjectSelect(xml_copy) self.changeSubObjectSelect(xml_copy)
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
from Globals import PersistentMapping from Globals import PersistentMapping
from time import gmtime,strftime # for anchors from time import gmtime, strftime # for anchors
from SyncCode import SyncCode from SyncCode import SyncCode
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
...@@ -91,8 +91,8 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -91,8 +91,8 @@ class Subscription(Folder, XMLSyncUtils):
""" """
meta_type='ERP5 Subscription' meta_type = 'ERP5 Subscription'
portal_type='SyncML Subscription' # may be useful in the future... portal_type = 'SyncML Subscription' # may be useful in the future...
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
icon = None icon = None
...@@ -144,7 +144,7 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -144,7 +144,7 @@ class Subscription(Folder, XMLSyncUtils):
self.next_anchor = '00000000T000000Z' self.next_anchor = '00000000T000000Z'
self.setMediaType(media_type) self.setMediaType(media_type)
self.login = login self.login = login
self.password=password self.password = password
self.domain_type = self.SUB self.domain_type = self.SUB
self.gpg_key = gpg_key self.gpg_key = gpg_key
self.setSynchronizationIdGenerator(id_generator) self.setSynchronizationIdGenerator(id_generator)
...@@ -164,7 +164,8 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -164,7 +164,8 @@ class Subscription(Folder, XMLSyncUtils):
self.alert_code = int(value) self.alert_code = int(value)
def isOneWayFromServer(self): def isOneWayFromServer(self):
return self.getDomainType() == self.SUB and self.getAlertCode() == self.ONE_WAY_FROM_SERVER return self.getDomainType() == self.SUB and \
self.getAlertCode() == self.ONE_WAY_FROM_SERVER
def getActivityEnabled(self): def getActivityEnabled(self):
""" """
...@@ -182,7 +183,7 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -182,7 +183,7 @@ class Subscription(Folder, XMLSyncUtils):
""" """
getter for title getter for title
""" """
return getattr(self,'title',None) return getattr(self, 'title', None)
def setTitle(self, value): def setTitle(self, value):
""" """
...@@ -292,8 +293,6 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -292,8 +293,6 @@ class Subscription(Folder, XMLSyncUtils):
return True if the message id was not seen, False if already seen return True if the message id was not seen, False if already seen
""" """
last_message_id = getattr(self, 'last_message_id', None) last_message_id = getattr(self, 'last_message_id', None)
#LOG('checkCorrectRemoteMessageId last_message_id = ', DEBUG, last_message_id)
#LOG('checkCorrectRemoteMessageId message_id = ', DEBUG, message_id)
if last_message_id == message_id: if last_message_id == message_id:
return False return False
self.last_message_id = message_id self.last_message_id = message_id
...@@ -483,8 +482,7 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -483,8 +482,7 @@ class Subscription(Folder, XMLSyncUtils):
def getGidFromObject(self, object): def getGidFromObject(self, object):
""" """
GetGidFromObject is return the gid for mapping between server and Returns the object gid
client
""" """
o_base = aq_base(object) o_base = aq_base(object)
o_gid = None o_gid = None
...@@ -522,12 +520,10 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -522,12 +520,10 @@ class Subscription(Folder, XMLSyncUtils):
o_id = signature.getObjectId() o_id = signature.getObjectId()
#try with id param too, because gid is not catalogged #try with id param too, because gid is not catalogged
object_list = self.getObjectList(gid=b16decode(gid), id=o_id) object_list = self.getObjectList(gid=b16decode(gid), id=o_id)
#LOG('getObjectFromGid :', DEBUG, 'object_list=%s, gid=%s, o_id=%s' % (object_list, gid, o_id))
if o is not None and o in object_list: if o is not None and o in object_list:
return o return o
#LOG('entering in the slow loop of getObjectFromGid !!!',0,'') #LOG('entering in the slow loop of getObjectFromGid !!!',0,'')
object_list = self.getObjectList(gid=b16decode(gid)) object_list = self.getObjectList(gid=b16decode(gid))
#LOG('getObjectFromGid :', DEBUG, 'object_list slow loop=%s, gid=%s' % (object_list, gid))
for o in object_list: for o in object_list:
o_gid = self.getGidFromObject(o) o_gid = self.getGidFromObject(o)
if o_gid == gid: if o_gid == gid:
...@@ -890,7 +886,8 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -890,7 +886,8 @@ class Subscription(Folder, XMLSyncUtils):
#elif format is .... put here the other formats #elif format is .... put here the other formats
else:#if there is no format corresponding with format, raise an error else:#if there is no format corresponding with format, raise an error
LOG('encode : unknown or not implemented format : ', INFO, format) LOG('encode : unknown or not implemented format : ', INFO, format)
raise ValueError, "Sorry, the server ask for the format %s but it's unknow or not implemented" % format raise ValueError, "Sorry, the server ask for the format %s but \
it's unknow or not implemented" % format
def decode(self, format, string_to_decode): def decode(self, format, string_to_decode):
""" """
...@@ -904,7 +901,8 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -904,7 +901,8 @@ class Subscription(Folder, XMLSyncUtils):
#elif format is .... put here the other formats #elif format is .... put here the other formats
else:#if there is no format corresponding with format, raise an error else:#if there is no format corresponding with format, raise an error
LOG('decode : unknown or not implemented format :', INFO, format) LOG('decode : unknown or not implemented format :', INFO, format)
raise ValueError, "Sorry, the format %s is unknow or not implemented" % format raise ValueError, "Sorry, the format %s is unknow or \
not implemented" % format
def isDecodeEncodeTheSame(self, string_encoded, string_decoded, format): def isDecodeEncodeTheSame(self, string_encoded, string_decoded, format):
""" """
......
...@@ -302,18 +302,20 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -302,18 +302,20 @@ class XMLSyncUtilsMixin(SyncCode):
#server.sendmail(fromaddr, "seb@localhost", msg) #server.sendmail(fromaddr, "seb@localhost", msg)
server.quit() server.quit()
def getNamespace(self,nsmap): def getNamespace(self, nsmap):
""" """
return the namespace with prefix of xml Set the namespace prefix, check if argument is conform
and return the full namespace updated for syncml
nsmap -- The namespace of the received xml
""" """
#search urn compatible in the namespaces of nsmap #search urn compatible in the namespaces of nsmap
urns = filter(lambda v: v.upper() in self.URN_LIST, nsmap.values()) urns = filter(lambda v: v.upper() in self.URN_LIST, nsmap.values())
if urns : if urns:
namespace = etree.FunctionNamespace(urns[0]) namespace = etree.FunctionNamespace(urns[0])
namespace.prefix='syncml' namespace.prefix = 'syncml'
return namespace return namespace
else : else:
raise ValueError, "Sorry, If have a namespace isn't supported" raise ValueError, "Sorry, the given namespace is not supported"
def addXMLObject(self, cmd_id=0, object=None, xml_string=None, def addXMLObject(self, cmd_id=0, object=None, xml_string=None,
more_data=0, gid=None, media_type=None): more_data=0, gid=None, media_type=None):
......
...@@ -66,7 +66,7 @@ class IConduit(Interface): ...@@ -66,7 +66,7 @@ class IConduit(Interface):
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""" """
def constructContent(self, object, object_id, portal_type): def constructContent(object, object_id, portal_type):
""" """
This allows to specify how to construct a new content. This allows to specify how to construct a new content.
This is really usefull if you want to write your This is really usefull if you want to write your
...@@ -81,7 +81,7 @@ class IConduit(Interface): ...@@ -81,7 +81,7 @@ class IConduit(Interface):
return newObject, reset_local_roles boolean, reset_workflow boolean return newObject, reset_local_roles boolean, reset_workflow boolean
""" """
def addNode(self, xml=None, object=None, previous_xml=None, def addNode(xml=None, object=None, previous_xml=None,
object_id=None, sub_object=None, force=0, simulate=0, **kw): object_id=None, sub_object=None, force=0, simulate=0, **kw):
""" """
A node is added A node is added
...@@ -99,13 +99,13 @@ class IConduit(Interface): ...@@ -99,13 +99,13 @@ class IConduit(Interface):
[object.getPath(),keyword,local_and_actual_value,subscriber_value] [object.getPath(),keyword,local_and_actual_value,subscriber_value]
""" """
def deleteNode(self, xml=None, object=None, object_id=None, force=None, def deleteNode(xml=None, object=None, object_id=None, force=None,
simulate=0, **kw): simulate=0, **kw):
""" """
A node is deleted A node is deleted
""" """
def updateNode(self, xml=None, object=None, previous_xml=None, force=0, def updateNode(xml=None, object=None, previous_xml=None, force=0,
simulate=0, **kw): simulate=0, **kw):
""" """
A node is updated with some xupdate A node is updated with some xupdate
...@@ -116,12 +116,12 @@ class IConduit(Interface): ...@@ -116,12 +116,12 @@ class IConduit(Interface):
""" """
def getGidFromObject(self, object): def getGidFromObject(object):
""" """
return the Gid composed with the object informations return the Gid composed with the object informations
""" """
def getGidFromXML(self, xml, namespace, gid_from_xml_list): def getGidFromXML(xml, namespace, gid_from_xml_list):
""" """
return the Gid composed with xml informations return the Gid composed with xml informations
""" """
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment