Commit e891a01b authored by Nicolas Delaby's avatar Nicolas Delaby

hide logs

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14702 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4997ff4e
This diff is collapsed.
...@@ -533,7 +533,7 @@ class Signature(Folder,SyncCode): ...@@ -533,7 +533,7 @@ class Signature(Folder,SyncCode):
# LOG('delConflict, conflict',0,conflict) # LOG('delConflict, conflict',0,conflict)
conflict_list = [] conflict_list = []
for c in self.getConflictList(): for c in self.getConflictList():
LOG('delConflict, c==conflict',0,c==aq_base(conflict)) #LOG('delConflict, c==conflict',0,c==aq_base(conflict))
if c != aq_base(conflict): if c != aq_base(conflict):
conflict_list += [c] conflict_list += [c]
if conflict_list != []: if conflict_list != []:
...@@ -969,7 +969,7 @@ class Subscription(Folder, SyncCode): ...@@ -969,7 +969,7 @@ class Subscription(Folder, SyncCode):
# It might be a script python # It might be a script python
generator = getattr(object,gid_gen) generator = getattr(object,gid_gen)
o_gid = generator() # XXX - used to be o_gid = generator(object=object) which is redundant o_gid = generator() # XXX - used to be o_gid = generator(object=object) which is redundant
LOG('getGidFromObject',0,'o_gid: %s' % repr(o_gid)) #LOG('getGidFromObject',0,'o_gid: %s' % repr(o_gid))
return o_gid return o_gid
def getObjectFromGid(self, gid): def getObjectFromGid(self, gid):
...@@ -1043,10 +1043,10 @@ class Subscription(Folder, SyncCode): ...@@ -1043,10 +1043,10 @@ class Subscription(Folder, SyncCode):
generator = getattr(object, id_generator) generator = getattr(object, id_generator)
new_id = generator() new_id = generator()
else: else:
# This is probably a python scrip # This is probably a python script
generator = getattr(object, id_generator) generator = getattr(object, id_generator)
new_id = generator(object=object,gid=gid) new_id = generator(object=object,gid=gid)
LOG('generateNewId, new_id: ',0,new_id) #LOG('generateNewId, new_id: ',0,new_id)
return new_id return new_id
return None return None
...@@ -1332,7 +1332,7 @@ class Subscription(Folder, SyncCode): ...@@ -1332,7 +1332,7 @@ class Subscription(Folder, SyncCode):
return b64encode(string_to_encode) return b64encode(string_to_encode)
#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 :', 0, format) #LOG('encode : unknown or not implemented format :', 0, 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):
...@@ -1346,7 +1346,7 @@ class Subscription(Folder, SyncCode): ...@@ -1346,7 +1346,7 @@ class Subscription(Folder, SyncCode):
return b64decode(string_to_decode) return b64decode(string_to_decode)
#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 :', 0, format) #LOG('decode : unknown or not implemented format :', 0, 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):
......
...@@ -39,7 +39,7 @@ class SubscriptionSynchronization(XMLSyncUtils): ...@@ -39,7 +39,7 @@ class SubscriptionSynchronization(XMLSyncUtils):
""" """
Send the first XML message from the client Send the first XML message from the client
""" """
LOG('SubSyncInit',0,'starting....') #LOG('SubSyncInit',0,'starting....')
cmd_id = 1 # specifies a SyncML message-unique command identifier cmd_id = 1 # specifies a SyncML message-unique command identifier
subscription.NewAnchor() subscription.NewAnchor()
subscription.initLastMessageId() subscription.initLastMessageId()
...@@ -83,8 +83,8 @@ class SubscriptionSynchronization(XMLSyncUtils): ...@@ -83,8 +83,8 @@ class SubscriptionSynchronization(XMLSyncUtils):
""" """
This is the synchronization method for the client This is the synchronization method for the client
""" """
LOG('SubSync',0,'starting... id: %s' % str(id)) #LOG('SubSync',0,'starting... id: %s' % str(id))
LOG('SubSync',0,'starting... msg: %s' % str(msg)) #LOG('SubSync',0,'starting... msg: %s' % str(msg))
response = None #check if subsync replies to this messages response = None #check if subsync replies to this messages
subscription = self.getSubscription(id) subscription = self.getSubscription(id)
...@@ -132,8 +132,8 @@ class SubscriptionSynchronization(XMLSyncUtils): ...@@ -132,8 +132,8 @@ class SubscriptionSynchronization(XMLSyncUtils):
This method send crendentials This method send crendentials
""" """
LOG('SubSyncCred',0,'starting... id: %s' % str(id)) #LOG('SubSyncCred',0,'starting... id: %s' % str(id))
LOG('SubSyncCred',0,'starting... msg: %s' % str(msg)) #LOG('SubSyncCred',0,'starting... msg: %s' % str(msg))
cmd_id = 1 # specifies a SyncML message-unique command identifier cmd_id = 1 # specifies a SyncML message-unique command identifier
subscription = self.getSubscription(id) subscription = self.getSubscription(id)
......
...@@ -33,6 +33,7 @@ from DateTime import DateTime ...@@ -33,6 +33,7 @@ from DateTime import DateTime
from cStringIO import StringIO from cStringIO import StringIO
from xml.dom.ext import PrettyPrint from xml.dom.ext import PrettyPrint
import random import random
from zLOG import LOG
try: try:
from Products.CMFActivity.ActiveObject import ActiveObject from Products.CMFActivity.ActiveObject import ActiveObject
except ImportError: except ImportError:
...@@ -40,7 +41,7 @@ except ImportError: ...@@ -40,7 +41,7 @@ except ImportError:
class ActiveObject: class ActiveObject:
pass pass
import commands import commands
from zLOG import LOG
try: try:
from Ft.Xml import Parse from Ft.Xml import Parse
except ImportError: except ImportError:
...@@ -189,7 +190,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -189,7 +190,7 @@ class XMLSyncUtilsMixin(SyncCode):
header = "Subject: %s\n" % id_sync header = "Subject: %s\n" % id_sync
header += "To: %s\n\n" % toaddr header += "To: %s\n\n" % toaddr
msg = header + msg msg = header + msg
LOG('SubSendMail',0,'from: %s, to: %s' % (fromaddr,toaddr)) #LOG('SubSendMail',0,'from: %s, to: %s' % (fromaddr,toaddr))
server = smtplib.SMTP('localhost') server = smtplib.SMTP('localhost')
server.sendmail(fromaddr, toaddr, msg) server.sendmail(fromaddr, toaddr, msg)
# if we want to send the email to someone else (debugging) # if we want to send the email to someone else (debugging)
...@@ -305,7 +306,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -305,7 +306,7 @@ class XMLSyncUtilsMixin(SyncCode):
xml = xml_method() xml = xml_method()
else: else:
raise ValueError, "Sorry the script or method was not found" raise ValueError, "Sorry the script or method was not found"
LOG('getXMLObject', 0, 'xml_mapping:%s, xml:%s, object:%s xml_method:%s' % (xml_mapping, xml, object, xml_method)) #LOG('getXMLObject', 0, 'xml_mapping:%s, xml:%s, object:%s xml_method:%s' % (xml_mapping, xml, object, xml_method))
return xml return xml
def getSessionId(self, xml): def getSessionId(self, xml):
...@@ -515,7 +516,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -515,7 +516,7 @@ class XMLSyncUtilsMixin(SyncCode):
first_node = xml_stream.childNodes[0] first_node = xml_stream.childNodes[0]
client_body = first_node.childNodes[3] client_body = first_node.childNodes[3]
if client_body.nodeName != "SyncBody": if client_body.nodeName != "SyncBody":
LOG('getNextSyncBodyStatus',0,"This is not a SyncML Body") #LOG('getNextSyncBodyStatus',0,"This is not a SyncML Body")
raise ValueError, "Sorry, This is not a SyncML Body" raise ValueError, "Sorry, This is not a SyncML Body"
next_status = None next_status = None
found = None found = None
...@@ -810,7 +811,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -810,7 +811,7 @@ class XMLSyncUtilsMixin(SyncCode):
if(subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']): if(subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']):
xml_string = self.getXMLObject(object=object, xml_string = self.getXMLObject(object=object,
xml_mapping=domain.xml_mapping) xml_mapping=domain.xml_mapping)
LOG('xml_string =', 0, xml_string) #LOG('xml_string =', 0, xml_string)
if signature.getAction()=='Replace': if signature.getAction()=='Replace':
syncml_data += self.replaceXMLObject(cmd_id=cmd_id, object=object, syncml_data += self.replaceXMLObject(cmd_id=cmd_id, object=object,
gid=object_gid, xml_string=xml_string, more_data=more_data, gid=object_gid, xml_string=xml_string, more_data=more_data,
...@@ -841,12 +842,12 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -841,12 +842,12 @@ class XMLSyncUtilsMixin(SyncCode):
signature = subscriber.getSignature(object_gid) signature = subscriber.getSignature(object_gid)
object = domain.getObjectFromGid(object_gid) object = domain.getObjectFromGid(object_gid)
if signature == None: if signature == None:
LOG('applyActionList, signature is None',0,signature) #LOG('applyActionList, signature is None',0,signature)
signature = Signature(gid=object_gid, status=self.NOT_SYNCHRONIZED, signature = Signature(gid=object_gid, status=self.NOT_SYNCHRONIZED,
object=object).__of__(subscriber) object=object).__of__(subscriber)
subscriber.addSignature(signature) subscriber.addSignature(signature)
force = signature.getForce() force = signature.getForce()
LOG('applyActionList',0,'object: %s' % repr(object)) #LOG('applyActionList',0,'object: %s' % repr(object))
if self.checkActionMoreData(next_action) == 0: if self.checkActionMoreData(next_action) == 0:
data_subnode = None data_subnode = None
if partial_data != None: if partial_data != None:
...@@ -855,7 +856,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -855,7 +856,7 @@ class XMLSyncUtilsMixin(SyncCode):
data_subnode = signature.getPartialXML() + partial_data data_subnode = signature.getPartialXML() + partial_data
else: else:
data_subnode = partial_data data_subnode = partial_data
LOG('SyncModif',0,'data_subnode: %s' % data_subnode) #LOG('SyncModif',0,'data_subnode: %s' % data_subnode)
#data_subnode = FromXml(data_subnode) #data_subnode = FromXml(data_subnode)
if subscriber.getMediaType() == self.MEDIA_TYPE['TEXT_XML']: if subscriber.getMediaType() == self.MEDIA_TYPE['TEXT_XML']:
data_subnode = Parse(data_subnode) data_subnode = Parse(data_subnode)
...@@ -877,10 +878,10 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -877,10 +878,10 @@ class XMLSyncUtilsMixin(SyncCode):
conflict_list += add_data['conflict_list'] conflict_list += add_data['conflict_list']
# Retrieve directly the object from addNode # Retrieve directly the object from addNode
object = add_data['object'] object = add_data['object']
LOG('XMLSyncUtils, in ADD add_data',0,add_data) #LOG('XMLSyncUtils, in ADD add_data',0,add_data)
if object is not None: if object is not None:
signature.setPath(object.getPhysicalPath()) signature.setPath(object.getPhysicalPath())
LOG('applyActionList',0,'object after add: %s' % repr(object)) #LOG('applyActionList',0,'object after add: %s' % repr(object))
else: else:
#Object was retrieve but need to be updated without recreated #Object was retrieve but need to be updated without recreated
#usefull when an object is only deleted by workflow. #usefull when an object is only deleted by workflow.
...@@ -892,7 +893,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -892,7 +893,7 @@ class XMLSyncUtilsMixin(SyncCode):
if add_data['conflict_list'] not in ('', None, []): if add_data['conflict_list'] not in ('', None, []):
conflict_list += add_data['conflict_list'] conflict_list += add_data['conflict_list']
if object is not None: if object is not None:
LOG('SyncModif',0,'addNode, found the object') #LOG('SyncModif',0,'addNode, found the object')
#mapping = getattr(object,domain.getXMLMapping(),None) #mapping = getattr(object,domain.getXMLMapping(),None)
xml_object = domain.getXMLFromObject(object) xml_object = domain.getXMLFromObject(object)
#if mapping is not None: #if mapping is not None:
...@@ -905,11 +906,11 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -905,11 +906,11 @@ class XMLSyncUtilsMixin(SyncCode):
self.SyncMLConfirmation(cmd_id,object_gid,self.SUCCESS,'Add') self.SyncMLConfirmation(cmd_id,object_gid,self.SUCCESS,'Add')
cmd_id +=1 cmd_id +=1
elif next_action.nodeName == 'Replace': elif next_action.nodeName == 'Replace':
LOG('SyncModif',0,'object: %s will be updated...' % str(object)) #LOG('SyncModif',0,'object: %s will be updated...' % str(object))
if object is not None: if object is not None:
LOG('SyncModif',0,'object: %s will be updated...' % object.id) #LOG('SyncModif',0,'object: %s will be updated...' % object.id)
signature = subscriber.getSignature(object_gid) signature = subscriber.getSignature(object_gid)
LOG('SyncModif',0,'previous signature: %s' % str(signature)) #LOG('SyncModif',0,'previous signature: %s' % str(signature))
previous_xml = signature.getXML() previous_xml = signature.getXML()
#LOG('SyncModif',0,'previous signature: %i' % len(previous_xml)) #LOG('SyncModif',0,'previous signature: %i' % len(previous_xml))
conflict_list += conduit.updateNode(xml=data_subnode, object=object, conflict_list += conduit.updateNode(xml=data_subnode, object=object,
...@@ -941,7 +942,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -941,7 +942,7 @@ class XMLSyncUtilsMixin(SyncCode):
string_io = StringIO() string_io = StringIO()
PrettyPrint(data_subnode,stream=string_io) PrettyPrint(data_subnode,stream=string_io)
data_subnode_string = string_io.getvalue() data_subnode_string = string_io.getvalue()
LOG('applyActionList, subscriber_xupdate:',0,data_subnode_string) #LOG('applyActionList, subscriber_xupdate:',0,data_subnode_string)
signature.setSubscriberXupdate(data_subnode_string) signature.setSubscriberXupdate(data_subnode_string)
elif next_action.nodeName == 'Delete': elif next_action.nodeName == 'Delete':
...@@ -963,7 +964,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -963,7 +964,7 @@ class XMLSyncUtilsMixin(SyncCode):
previous_partial += partial_data previous_partial += partial_data
signature.setPartialXML(previous_partial) signature.setPartialXML(previous_partial)
#LOG('SyncModif',0,'previous_partial: %s' % str(previous_partial)) #LOG('SyncModif',0,'previous_partial: %s' % str(previous_partial))
LOG('SyncModif',0,'waiting more data for :%s' % signature.getId()) #LOG('SyncModif',0,'waiting more data for :%s' % signature.getId())
xml_confirmation += self.SyncMLConfirmation(cmd_id, object_gid, xml_confirmation += self.SyncMLConfirmation(cmd_id, object_gid,
self.WAITING_DATA, next_action.nodeName) self.WAITING_DATA, next_action.nodeName)
if conflict_list != [] and signature is not None: if conflict_list != [] and signature is not None:
...@@ -979,7 +980,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -979,7 +980,7 @@ class XMLSyncUtilsMixin(SyncCode):
This method have to change status codes on signatures This method have to change status codes on signatures
""" """
next_status = self.getNextSyncBodyStatus(remote_xml, None) next_status = self.getNextSyncBodyStatus(remote_xml, None)
LOG('applyStatusList, next_status',0,next_status) #LOG('applyStatusList, next_status',0,next_status)
# We do not want the first one # We do not want the first one
next_status = self.getNextSyncBodyStatus(remote_xml, next_status) next_status = self.getNextSyncBodyStatus(remote_xml, next_status)
has_status_list = 0 has_status_list = 0
...@@ -991,7 +992,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -991,7 +992,7 @@ class XMLSyncUtilsMixin(SyncCode):
status_code = self.getStatusCode(next_status) status_code = self.getStatusCode(next_status)
status_cmd = self.getStatusCommand(next_status) status_cmd = self.getStatusCommand(next_status)
signature = subscriber.getSignature(object_gid) signature = subscriber.getSignature(object_gid)
LOG('SyncModif',0,'next_status: %s' % str(status_code)) #LOG('SyncModif',0,'next_status: %s' % str(status_code))
if status_cmd in ('Add','Replace'): if status_cmd in ('Add','Replace'):
if status_code == self.CHUNK_OK: if status_code == self.CHUNK_OK:
destination_waiting_more_data = 1 destination_waiting_more_data = 1
...@@ -1043,7 +1044,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1043,7 +1044,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
from Products.ERP5SyncML import Conduit from Products.ERP5SyncML import Conduit
has_response = 0 #check if syncmodif replies to this messages has_response = 0 #check if syncmodif replies to this messages
cmd_id = 1 # specifies a SyncML message-unique command identifier cmd_id = 1 # specifies a SyncML message-unique command identifier
LOG('SyncModif',0,'Starting... domain: %s' % str(domain)) #LOG('SyncModif',0,'Starting... domain: %s' % str(domain))
# Get the destination folder # Get the destination folder
destination_path = self.unrestrictedTraverse(domain.getDestinationPath()) destination_path = self.unrestrictedTraverse(domain.getDestinationPath())
...@@ -1051,7 +1052,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1051,7 +1052,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
# Get informations from the header # Get informations from the header
xml_header = first_node.childNodes[1] xml_header = first_node.childNodes[1]
if xml_header.nodeName != "SyncHdr": if xml_header.nodeName != "SyncHdr":
LOG('PubSyncModif',0,'This is not a SyncML Header') #LOG('PubSyncModif',0,'This is not a SyncML Header')
raise ValueError, "Sorry, This is not a SyncML Header" raise ValueError, "Sorry, This is not a SyncML Header"
subscriber = domain # If we are the client, this is fine subscriber = domain # If we are the client, this is fine
...@@ -1072,9 +1073,9 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1072,9 +1073,9 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
message_id = self.getMessageId(remote_xml) message_id = self.getMessageId(remote_xml)
correct_message = subscriber.checkCorrectRemoteMessageId(message_id) correct_message = subscriber.checkCorrectRemoteMessageId(message_id)
if not correct_message: # We need to send again the message if not correct_message: # We need to send again the message
LOG('SyncModif, no correct message:',0,"sending again...") #LOG('SyncModif, no correct message:',0,"sending again...")
last_xml = subscriber.getLastSentMessage() last_xml = subscriber.getLastSentMessage()
LOG("last_xml :", 0, last_xml) #LOG("last_xml :", 0, last_xml)
if last_xml != '': if last_xml != '':
has_response = 1 has_response = 1
if domain.domain_type == self.PUB: # We always reply if domain.domain_type == self.PUB: # We always reply
......
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