[Erp5-report] r27394 - /erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jun 5 15:27:52 CEST 2009


Author: ivan
Date: Fri Jun  5 15:27:49 2009
New Revision: 27394

URL: http://svn.erp5.org?rev=27394&view=rev
Log:
Use already existing generic web service tool.

Modified:
    erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py

Modified: erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py?rev=27394&r1=27393&r2=27394&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py [utf8] Fri Jun  5 15:27:49 2009
@@ -47,7 +47,6 @@
 from DateTime import DateTime
 from Products.PluggableAuthService.interfaces.plugins import IAuthenticationPlugin
 from Products.ERP5Type.Cache import CachingMethod
-from urlparse import urlparse
 
 # global (RAM) cookie storage
 cookiejar = cookielib.CookieJar()
@@ -379,11 +378,16 @@
     finally:
       f.close()
 
-  def _getRemoteWitchTool(self, server_url):
-    """ Return remote generator tool interface. """
-    server = xmlrpclib.ServerProxy(server_url, allow_none=1)
-    witch_tool = server.portal_witch
-    return witch_tool
+  def _getRemoteWitchTool(self, url, user_name=None, password=None):
+    """ 
+      Return remote portal_witch tool interface.
+    """
+    handle = self.getPortalObject().portal_web_services.connect(
+                                      url = url, \
+                                      user_name = user_name, \
+                                      password = password, \
+                                      transport = 'xml-rpc')
+    return handle.portal_witch
 
   def callRemoteProxyMethod(self, distant_method, server_url=None, use_cache=1, **kw):
     """ Call proxy method on server. """
@@ -401,7 +405,8 @@
   def _callRemoteMethod(self, distant_method, server_url=None, use_proxy=0, **kw):
     """ Call remote method on server and get result. """
     result_call = GeneratorCall()
-    friendly_server_url = server_url
+    user_name = None
+    password = None
     if server_url is None:
       # calculate it
       server_url = self.getServerUrl() + self.getServerRoot()
@@ -409,12 +414,8 @@
       user_and_password = self._getSubsribedUserAndPassword()
       if (len(user_and_password)==2 and
           user_and_password[0] and user_and_password[1]):
-        friendly_server_url = server_url
-        schema = urlparse(server_url)
-        server_url = '%s://%s@%s%s' %(schema[0], 
-                         '%s:%s' %(user_and_password[0], user_and_password[1]), \
-                         schema[1], schema[2])
-    witch_tool = self._getRemoteWitchTool(server_url)
+        user_name, password = user_and_password
+    witch_tool = self._getRemoteWitchTool(server_url, user_name, password)
     parameter_dict = self.REQUEST.form.copy()
     if use_proxy:
       # add remote method arguments
@@ -431,7 +432,7 @@
       html = method(parameter_dict)
     except socket.error, message:
       html = _generateErrorXML("""Cannot contact the server: %s.
-                                  Please check your network settings."""  %friendly_server_url)
+                                  Please check your network settings."""  %server_url)
       zLOG.LOG('Wizard Tool socket error', zLOG.ERROR, message)
       result_call.update({"command": "show",
                           "data": html,
@@ -439,14 +440,14 @@
                           "previous": None})
     except xmlrpclib.ProtocolError, message:
       html = _generateErrorXML("""The server %s refused to reply.
-                                  Please contact erp5-dev at erp5.org""" %friendly_server_url)
+                                  Please contact erp5-dev at erp5.org""" %server_url)
       zLOG.LOG('Wizard Tool xmlrpc protocol error', zLOG.ERROR, message)
       result_call.update({"command": "show",
                           "data": html,
                           "next": None,
                           "previous": None})
     except xmlrpclib.Fault, message:
-      html = _generateErrorXML("Error/bug inside the server: %s." %friendly_server_url)
+      html = _generateErrorXML("Error/bug inside the server: %s." %server_url)
       zLOG.LOG('Wizard Tool xmlrpc fault', zLOG.ERROR, message)
       result_call.update({"command": "show",
                           "data": html,




More information about the Erp5-report mailing list