Commit 640654ed authored by Ivan Tyagov's avatar Ivan Tyagov

Extend remote method caller API.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29970 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent be553671
...@@ -389,11 +389,14 @@ class WizardTool(BaseTool): ...@@ -389,11 +389,14 @@ class WizardTool(BaseTool):
transport = 'xml-rpc') transport = 'xml-rpc')
return handle.portal_witch return handle.portal_witch
def callRemoteProxyMethod(self, distant_method, server_url=None, use_cache=1, **kw): def callRemoteProxyMethod(self, distant_method, server_url=None, \
use_cache=1, ignore_exceptions=1, **kw):
""" Call proxy method on server. """ """ Call proxy method on server. """
configurator_user_preferred_language = self.getConfiguratorUserPreferredLanguage() configurator_user_preferred_language = self.getConfiguratorUserPreferredLanguage()
def wrapper(distant_method, **kw): def wrapper(distant_method, **kw):
return self._callRemoteMethod(distant_method, use_proxy=1, **kw)['data'] return self._callRemoteMethod(distant_method, \
use_proxy=1, \
ignore_exceptions=ignore_exceptions, **kw)['data']
if use_cache: if use_cache:
wrapper = CachingMethod(wrapper, wrapper = CachingMethod(wrapper,
id = 'callRemoteProxyMethod_%s_%s' id = 'callRemoteProxyMethod_%s_%s'
...@@ -402,7 +405,8 @@ class WizardTool(BaseTool): ...@@ -402,7 +405,8 @@ class WizardTool(BaseTool):
rc = wrapper(distant_method, **kw) rc = wrapper(distant_method, **kw)
return rc return rc
def _callRemoteMethod(self, distant_method, server_url=None, use_proxy=0, **kw): def _callRemoteMethod(self, distant_method, server_url=None, \
use_proxy=0, ignore_exceptions=1, **kw):
""" Call remote method on server and get result. """ """ Call remote method on server and get result. """
result_call = GeneratorCall() result_call = GeneratorCall()
user_name = None user_name = None
...@@ -426,6 +430,7 @@ class WizardTool(BaseTool): ...@@ -426,6 +430,7 @@ class WizardTool(BaseTool):
self._updateParameterDictWithServerInfo(parameter_dict) self._updateParameterDictWithServerInfo(parameter_dict)
## handle file upload ## handle file upload
self._updateParameterDictWithFileUpload(parameter_dict) self._updateParameterDictWithFileUpload(parameter_dict)
message = None
## call remote method ## call remote method
try: try:
method = getattr(witch_tool, distant_method) method = getattr(witch_tool, distant_method)
...@@ -457,6 +462,9 @@ class WizardTool(BaseTool): ...@@ -457,6 +462,9 @@ class WizardTool(BaseTool):
result_call.load(html) result_call.load(html)
command = result_call["command"] command = result_call["command"]
html = result_call["data"] html = result_call["data"]
if message is not None and not ignore_exceptions:
# raise last cought exception
raise
return result_call return result_call
def _setServerInfo(self, **kw): def _setServerInfo(self, **kw):
......
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