[Erp5-report] r25220 - /erp5/trunk/products/ERP5SyncML/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Jan 21 09:50:46 CET 2009
Author: nicolas
Date: Wed Jan 21 09:50:26 2009
New Revision: 25220
URL: http://svn.erp5.org?rev=25220&view=rev
Log:
replace last imports of 4Suite
Modified:
erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py
erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
erp5/trunk/products/ERP5SyncML/XupdateUtils.py
Modified: erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py?rev=25220&r1=25219&r2=25220&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py [utf8] Wed Jan 21 09:50:26 2009
@@ -2,23 +2,12 @@
# coding=UTF-8
import httplib
import urllib,urllib2, os
-from Ft.Xml import Parse
import cStringIO
import string
import socket
import time
from optparse import OptionParser
-try:
- from Ft.Xml.Domlette import Print, PrettyPrint
-except ImportError:
- class Print:
- def __init__(self, *args, **kw):
- raise ImportError, '4Suite-XML is not installed'
-
- class PrettyPrint:
- def __init__(self, *args, **kw):
- raise ImportError, '4Suite-XML is not installed'
-
+from lxml import etree
class OptionParser(OptionParser):
@@ -46,7 +35,7 @@
#address of this small server :
#Host = '192.168.242.247'
-Host=options.host
+Host = options.host
#address of the publication :
#publication_url = 'http://localhost:9080/erp5Serv'
@@ -57,10 +46,10 @@
#port of this server :
#Port = 1234
-Port=options.port
+Port = options.port
#address of the this server :
-syncml_server_url = 'http://'+Host+':'+str(Port)
+syncml_server_url = 'http://%s:%s' % (Host, Port)
#socket :
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
@@ -78,11 +67,7 @@
"""
return an xml string corresponding to the node
"""
- buf = cStringIO.StringIO()
- Print(node, stream=buf, encoding='utf-8')
- xml_string = buf.getvalue()
- buf.close()
- return xml_string
+ return etree.tostring(node, encoding='utf-8')
def xml2wbxml(xml):
"""
@@ -151,8 +136,8 @@
"""
find the client url in the text and return it
"""
- document = Parse(text)
- client_url = document.xpath('string(//SyncHdr/Source/LocURI)').encode('utf-8')
+ document = etree.XML(text)
+ client_url = '%s' % document.xpath('string(//SyncHdr/Source/LocURI)')
return client_url
def sendResponse(text, to_url, client_url):
@@ -166,7 +151,7 @@
print '\nsendResponse...'
- text=wbxml2xml(text)
+ text = wbxml2xml(text)
text = text.replace(syncml_server_url, publication_url)
text = text.replace(client_url, syncml_server_url)
@@ -209,7 +194,7 @@
if text.endswith('\x01\x01'):
client_url = getClientUrl(wbxml2xml(text))
response = sendResponse(text=text, to_url=to_url, client_url=client_url)
- if response not in ('', None):
+ if response:
response = response.replace(syncml_server_url, client_url)
response = response.replace(publication_url, syncml_server_url)
print "\nresponse = \n",response
Modified: erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SynchronizationTool.py?rev=25220&r1=25219&r2=25220&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SynchronizationTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/SynchronizationTool.py [utf8] Wed Jan 21 09:50:26 2009
@@ -1030,11 +1030,11 @@
if domain.getSyncContentType() == self.CONTENT_TYPE['SYNCML_WBXML']:
text = self.wbxml2xml(text)
#LOG('readResponse, text after wbxml :\n', TRACE, text)
- xml = Parse(text)
+ xml = etree.XML(text)
url = self.getTarget(xml)
for publication in self.getPublicationList():
if publication.getPublicationUrl()==url and \
- publication.getTitle()==sync_id:
+ publication.getTitle() == sync_id:
if publication.getActivityEnabled():
#use activities to send SyncML data.
activity = self.getActivityType(domain=publication)
Modified: erp5/trunk/products/ERP5SyncML/XupdateUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/XupdateUtils.py?rev=25220&r1=25219&r2=25220&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/XupdateUtils.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/XupdateUtils.py [utf8] Wed Jan 21 09:50:26 2009
@@ -42,20 +42,20 @@
Parse the xupdate and then it will call the conduit
"""
conflict_list = []
- if type(xupdate) in (type('a'),type(u'a')):
+ if isinstance(xupdate, (str, unicode)):
xupdate = FromXml(xupdate)
- for subnode in self.getElementNodeList(xupdate):
+ for subnode in xupdate:
selection_name = ''
- if subnode.nodeName in self.XUPDATE_INSERT_OR_ADD:
- conflict_list += conduit.addNode(xml=subnode, object=object, \
- force=force, **kw)
- elif subnode.nodeName in self.XUPDATE_DEL:
- conflict_list += conduit.deleteNode(xml=subnode, object=object, \
- force=force, **kw)
- elif subnode.nodeName in self.XUPDATE_UPDATE:
- conflict_list += conduit.updateNode(xml=subnode, object=object, \
- force=force, **kw)
+ if subnode.xpath('name()') in self.XUPDATE_INSERT_OR_ADD:
+ conflict_list.extend(conduit.addNode(xml=subnode, object=object, \
+ force=force, **kw))
+ elif subnode.xpath('name()') in self.XUPDATE_DEL:
+ conflict_list.extend(conduit.deleteNode(xml=subnode, object=object, \
+ force=force, **kw))
+ elif subnode.xpath('name()') in self.XUPDATE_UPDATE:
+ conflict_list.extend(conduit.updateNode(xml=subnode, object=object, \
+ force=force, **kw))
return conflict_list
More information about the Erp5-report
mailing list