Commit 43669437 authored by Ivan Tyagov's avatar Ivan Tyagov

Use already existing generic web service tool.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27394 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent acced39d
......@@ -47,7 +47,6 @@ from urllib import quote, unquote
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 @@ class WizardTool(BaseTool):
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 @@ class WizardTool(BaseTool):
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 @@ class WizardTool(BaseTool):
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 @@ class WizardTool(BaseTool):
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 @@ class WizardTool(BaseTool):
"previous": None})
except xmlrpclib.ProtocolError, message:
html = _generateErrorXML("""The server %s refused to reply.
Please contact erp5-dev@erp5.org""" %friendly_server_url)
Please contact erp5-dev@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,
......
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