[Erp5-report] r26876 - /erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu May 7 14:30:10 CEST 2009


Author: fabien
Date: Thu May  7 14:30:09 2009
New Revision: 26876

URL: http://svn.erp5.org?rev=26876&view=rev
Log:
fix some mistakes. Nothing is tested for this file
This file will be removed because a syncml server will be integrated to erp5

Modified:
    erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py

Modified: erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py?rev=26876&r1=26875&r2=26876&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py [utf8] Thu May  7 14:30:09 2009
@@ -20,15 +20,15 @@
           self.error("%s option not supplied" % option)
 
 
-parser = OptionParser()
-parser.add_option("--host", help="address of this small server (typically, it's the ip of this computer)")
-parser.add_option("--publication", help="address of the publication (e.g. http://localhost:9080/erp5Serv)")
-parser.add_option("-p", "--port", type="int", help="port used by this server (default is 1234)", default=1234)
-
-(options, args) = parser.parse_args()
-
-parser.check_required("--publication")
-parser.check_required("--host")
+cmd_parser = OptionParser()
+cmd_parser.add_option("--host", help="address of this small server (typically, it's the ip of this computer)")
+cmd_parser.add_option("--publication", help="address of the publication (e.g. http://localhost:9080/erp5Serv)")
+cmd_parser.add_option("-p", "--port", type="int", help="port used by this server (default is 1234)", default=1234)
+
+(options, args) = cmd_parser.parse_args()
+
+cmd_parser.check_required("--publication")
+cmd_parser.check_required("--host")
 
 
 
@@ -54,6 +54,8 @@
 
 #socket :
 sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # reuse the same socket
+                                                        # if already open
 
 #END CONFIGURATION SECTION
 
@@ -75,6 +77,9 @@
   convert xml string to wbxml using a temporary file
   """
   import os
+
+  # XXX we must check at the begining if xml2wbxml is installed
+  # it seems that now there is a python biding for this : pywbxml
   f = open('/tmp/xml2wbxml', 'w')
   f.write(xml)
   f.close()
@@ -138,7 +143,10 @@
   find the client url in the text and return it
   """
   document = etree.XML(text, parser=parser)
+  # XXX this xpath expression have to be rewrited in a generic way to handle
+  # namspace
   client_url = '%s' % document.xpath('string(//SyncHdr/Source/LocURI)')
+  # client_url = '%s' % document.xpath('string(//syncml:SyncHdr/syncml:Source/syncml:LocURI)', namespaces={'syncml':'SYNCML:SYNCML1.2'})
   return client_url 
 
 def sendResponse(text, to_url, client_url):
@@ -157,7 +165,7 @@
   text = text.replace(client_url, syncml_server_url)
 
   print "text = ",text
-  to_encode['text'] = text 
+  to_encode['text'] = text
   to_encode['sync_id'] = 'Person'
   headers = {'Content-type': 'application/vnd.syncml+xml'}
 




More information about the Erp5-report mailing list