Commit 0c829029 authored by Ivan Tyagov's avatar Ivan Tyagov

Allow (by default) caching for callRemoteProxyMethod.

Refactory selection of configuration language in a separate function.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24502 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3fa32ce9
...@@ -383,13 +383,21 @@ class WizardTool(BaseTool): ...@@ -383,13 +383,21 @@ class WizardTool(BaseTool):
witch_tool = server.portal_witch witch_tool = server.portal_witch
return witch_tool return witch_tool
def callRemoteProxyMethod(self, distant_method, server_url=None): def callRemoteProxyMethod(self, distant_method, server_url=None, use_cache=1):
""" Call proxy method on server. """ """ Call proxy method on server. """
# set real method_id # set real method_id
form = self.REQUEST.form form = self.REQUEST.form
configurator_user_preferred_language = self.getConfiguratorUserPreferredLanguage()
def wrapper(distant_method):
form['method_id'] = distant_method form['method_id'] = distant_method
rc = self._callRemoteMethod('proxyMethodHandler') return self._callRemoteMethod('proxyMethodHandler')['data']
return rc['data'] if use_cache:
wrapper = CachingMethod(wrapper,
id = 'callRemoteProxyMethod_%s_%s'
%(distant_method, configurator_user_preferred_language),
cache_factory = 'erp5_ui_medium')
rc = wrapper(distant_method)
return rc
def _callRemoteMethod(self, distant_method, server_url=None, wrap_result=1): def _callRemoteMethod(self, distant_method, server_url=None, wrap_result=1):
""" Call remote method on server and get result. """ """ Call remote method on server and get result. """
...@@ -445,32 +453,32 @@ class WizardTool(BaseTool): ...@@ -445,32 +453,32 @@ class WizardTool(BaseTool):
self.setExpressConfigurationPreference(_server_to_preference_ids_map[item], self.setExpressConfigurationPreference(_server_to_preference_ids_map[item],
value) value)
def _updateParameterDictWithServerInfo(self, parameter_dict): def getConfiguratorUserPreferredLanguage(self):
"""Updates parameter_dict to include local saved server info settings. """ """ Get configuration language as selected by user """
global _server_to_preference_ids_map
for key, value in _server_to_preference_ids_map.items():
parameter_dict[key] = self.getExpressConfigurationPreference(value, None)
## add local ERP5 instance url
parameter_dict['erp5_url'] = self.getPortalObject().absolute_url()
# add user preffered language
REQUEST = getattr(self, 'REQUEST', None) REQUEST = getattr(self, 'REQUEST', None)
configurator_user_preferred_language = None configurator_user_preferred_language = None
if REQUEST is not None: if REQUEST is not None:
# language value will be in cookie or REQUEST itself. # language value will be in cookie or REQUEST itself.
configurator_user_preferred_language = REQUEST.get(LANGUAGE_COOKIE_NAME, None) configurator_user_preferred_language = REQUEST.get(LANGUAGE_COOKIE_NAME, None)
if configurator_user_preferred_language is None: if configurator_user_preferred_language is None:
# Find a preferred language from HTTP_ACCEPT_LANGUAGE # Find a preferred language from HTTP_ACCEPT_LANGUAGE
available_language_list = [i[1] for i in self.WizardTool_getConfigurationLanguageList()] available_language_list = [i[1] for i in self.WizardTool_getConfigurationLanguageList()]
configurator_user_preferred_language = getAvailableLanguageFromHttpAcceptLanguage( configurator_user_preferred_language = getAvailableLanguageFromHttpAcceptLanguage(
REQUEST.get('HTTP_ACCEPT_LANGUAGE', 'en'), REQUEST.get('HTTP_ACCEPT_LANGUAGE', 'en'),
available_language_list) available_language_list)
if configurator_user_preferred_language is None: if configurator_user_preferred_language is None:
configurator_user_preferred_language = 'en' configurator_user_preferred_language = 'en'
return configurator_user_preferred_language
parameter_dict['user_preferred_language'] = configurator_user_preferred_language def _updateParameterDictWithServerInfo(self, parameter_dict):
"""Updates parameter_dict to include local saved server info settings. """
global _server_to_preference_ids_map
for key, value in _server_to_preference_ids_map.items():
parameter_dict[key] = self.getExpressConfigurationPreference(value, None)
## add local ERP5 instance url
parameter_dict['erp5_url'] = self.getPortalObject().absolute_url()
# add user preffered language
parameter_dict['user_preferred_language'] = self.getConfiguratorUserPreferredLanguage()
def _updateParameterDictWithFileUpload(self, parameter_dict): def _updateParameterDictWithFileUpload(self, parameter_dict):
"""Updates parameter_dict to replace file upload with their file content, """Updates parameter_dict to replace file upload with their file content,
......
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