[Erp5-report] r25383 - /erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Jan 30 15:44:09 CET 2009
Author: ivan
Date: Fri Jan 30 15:44:07 2009
New Revision: 25383
URL: http://svn.erp5.org?rev=25383&view=rev
Log:
Use Basic Atuhentication (if possible) for XML-RPC calls.
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=25383&r1=25382&r2=25383&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Wizard/Tool/WizardTool.py [utf8] Fri Jan 30 15:44:07 2009
@@ -46,6 +46,7 @@
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()
@@ -399,9 +400,18 @@
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
if server_url is None:
# calculate it
server_url = self.getServerUrl() + self.getServerRoot()
+ # include authentication if possible
+ 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%s' %(schema[0], user_and_password[0], user_and_password[1],
+ schema[1], schema[2])
witch_tool = self._getRemoteWitchTool(server_url)
parameter_dict = self.REQUEST.form.copy()
if use_proxy:
@@ -419,7 +429,7 @@
html = method(parameter_dict)
except socket.error, message:
html = _generateErrorXML("""Cannot contact the server: %s.
- Please check your network settings.""" %server_url)
+ Please check your network settings.""" %friendly_server_url)
zLOG.LOG('Wizard Tool socket error', zLOG.ERROR, message)
result_call.update({"command": "show",
"data": html,
@@ -427,14 +437,14 @@
"previous": None})
except xmlrpclib.ProtocolError, message:
html = _generateErrorXML("""The server %s refused to reply.
- Please contact erp5-dev at erp5.org""" % server_url)
+ Please contact erp5-dev at erp5.org""" %friendly_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." % server_url)
+ html = _generateErrorXML("Error/bug inside the server: %s." %friendly_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