Commit 54126606 authored by Jérome Perrin's avatar Jérome Perrin

minor changes fixes


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22403 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 69447ce8
...@@ -202,8 +202,8 @@ class WizardTool(BaseTool): ...@@ -202,8 +202,8 @@ class WizardTool(BaseTool):
# and errors automatically. This is necessary because the proxy # and errors automatically. This is necessary because the proxy
# should pass all results to a client as they are. # should pass all results to a client as they are.
simple_opener_director = urllib2.OpenerDirector() simple_opener_director = urllib2.OpenerDirector()
for name in ('ProxyHandler', 'UnknownHandler', 'HTTPHandler', for name in ('ProxyHandler', 'UnknownHandler', 'HTTPHandler',
'FTPHandler', 'FileHandler', 'HTTPSHandler'): 'FTPHandler', 'FileHandler', 'HTTPSHandler'):
handler = getattr(urllib2, name, None) handler = getattr(urllib2, name, None)
if handler is not None: if handler is not None:
simple_opener_director.add_handler(handler()) simple_opener_director.add_handler(handler())
...@@ -235,7 +235,7 @@ class WizardTool(BaseTool): ...@@ -235,7 +235,7 @@ class WizardTool(BaseTool):
content_type_dict = None content_type_dict = None
if content_type: if content_type:
content_type_value, content_type_dict = cgi.parse_header(content_type) content_type_value, content_type_dict = cgi.parse_header(content_type)
if content_type_value=='multipart/form-data': if content_type_value == 'multipart/form-data':
fp = StringIO(user_input) fp = StringIO(user_input)
user_input_dict = cgi.parse_multipart(fp, content_type_dict) user_input_dict = cgi.parse_multipart(fp, content_type_dict)
else: else:
...@@ -258,7 +258,8 @@ class WizardTool(BaseTool): ...@@ -258,7 +258,8 @@ class WizardTool(BaseTool):
user_and_password = self._getSubsribedUserAndPassword() user_and_password = self._getSubsribedUserAndPassword()
if (len(user_and_password)==2 and if (len(user_and_password)==2 and
user_and_password[0] and user_and_password[1]): user_and_password[0] and user_and_password[1]):
auth = 'Basic %s' % base64.encodestring('%s:%s' % user_and_password).strip() auth = 'Basic %s' % base64.encodestring(
'%s:%s' % user_and_password).strip()
header_dict['Authorization'] = auth header_dict['Authorization'] = auth
if content_type: if content_type:
...@@ -308,30 +309,30 @@ class WizardTool(BaseTool): ...@@ -308,30 +309,30 @@ class WizardTool(BaseTool):
self._updateParameterDictWithFileUpload(parameter_dict) self._updateParameterDictWithFileUpload(parameter_dict)
## call remote method ## call remote method
try: try:
method = getattr(witch_tool, distant_method) method = getattr(witch_tool, distant_method)
html = method(parameter_dict) html = method(parameter_dict)
except socket.error, message: except socket.error, message:
html = _generateErrorXML("""Cannot contact the server: %s. html = _generateErrorXML("""Cannot contact the server: %s.
Please check your network settings.""" %server_url) Please check your network settings.""" %server_url)
zLOG.LOG('Wizard Tool socket error', zLOG.ERROR, message) zLOG.LOG('Wizard Tool socket error', zLOG.ERROR, message)
result_call.update({"command":"show", result_call.update({"command": "show",
"data": html, "data": html,
"next": None, "next": None,
"previous": None}) "previous": None})
except xmlrpclib.ProtocolError, message: except xmlrpclib.ProtocolError, message:
html = _generateErrorXML("""The server %s refused to reply. html = _generateErrorXML("""The server %s refused to reply.
Please contact erp5-dev@erp5.org""" % server_url) Please contact erp5-dev@erp5.org""" % server_url)
zLOG.LOG('Wizard Tool xmlrpc protocol error', zLOG.ERROR, message) zLOG.LOG('Wizard Tool xmlrpc protocol error', zLOG.ERROR, message)
result_call.update({"command":"show", result_call.update({"command": "show",
"data": html, "data": html,
"next": None, "next": None,
"previous": None}) "previous": None})
except xmlrpclib.Fault, message: except xmlrpclib.Fault, message:
html = _generateErrorXML("Error/bug inside the server: %s." % server_url) html = _generateErrorXML("Error/bug inside the server: %s." % server_url)
zLOG.LOG('Wizard Tool xmlrpc fault', zLOG.ERROR, message) zLOG.LOG('Wizard Tool xmlrpc fault', zLOG.ERROR, message)
result_call.update({"command":"show", result_call.update({"command": "show",
"data": html, "data": html,
"next": None, "next": None,
"previous": None}) "previous": None})
else: else:
result_call.load(html) result_call.load(html)
...@@ -341,7 +342,7 @@ class WizardTool(BaseTool): ...@@ -341,7 +342,7 @@ class WizardTool(BaseTool):
def _setServerInfo(self, **kw): def _setServerInfo(self, **kw):
""" Save to local Zope client address info. """ """ Save to local Zope client address info. """
global _server_to_preference_ids_map global _server_to_preference_ids_map
for item, value in kw.items(): for item, value in kw.items():
if item in _server_to_preference_ids_map.keys(): if item in _server_to_preference_ids_map.keys():
## save persistently (as preference) ## save persistently (as preference)
...@@ -383,13 +384,14 @@ class WizardTool(BaseTool): ...@@ -383,13 +384,14 @@ class WizardTool(BaseTool):
portal_workflow = getToolByName(self.getPortalObject(), 'portal_workflow') portal_workflow = getToolByName(self.getPortalObject(), 'portal_workflow')
business_template.install() business_template.install()
security.declareProtected(Permissions.ModifyPortalContent, 'installBT5FilesFromServer') security.declareProtected(Permissions.ModifyPortalContent,
def installBT5FilesFromServer(self, 'installBT5FilesFromServer')
server_response, def installBT5FilesFromServer(self,
execute_after_setup_script = True, server_response,
install_standard_bt5 = True, execute_after_setup_script=True,
install_customer_bt5 = True, install_standard_bt5=True,
use_super_manager = True): install_customer_bt5=True,
use_super_manager=True):
""" Install or update BT5 files which we get from remote server. """ """ Install or update BT5 files which we get from remote server. """
if use_super_manager: if use_super_manager:
# set current security manager to owner of site # set current security manager to owner of site
...@@ -400,8 +402,8 @@ class WizardTool(BaseTool): ...@@ -400,8 +402,8 @@ class WizardTool(BaseTool):
bt5_filenames = server_response["server_buffer"].get("filenames", []) bt5_filenames = server_response["server_buffer"].get("filenames", [])
portal_templates = getToolByName(portal, 'portal_templates') portal_templates = getToolByName(portal, 'portal_templates')
counter = 0 counter = 0
LOG("Wizard", INFO, LOG("Wizard", INFO,
"Starting installation for %s" %' '.join(bt5_filenames)) "Starting installation for %s" %' '.join(bt5_filenames))
#execute_after_setup_script = install_standard_bt5 = install_customer_bt5 = False # dev mode #execute_after_setup_script = install_standard_bt5 = install_customer_bt5 = False # dev mode
for bt5_id in bt5_filenames: for bt5_id in bt5_filenames:
if bt5_id.startswith('http://'): if bt5_id.startswith('http://'):
...@@ -409,23 +411,26 @@ class WizardTool(BaseTool): ...@@ -409,23 +411,26 @@ class WizardTool(BaseTool):
if install_standard_bt5: if install_standard_bt5:
bt = portal_templates.download(bt5_id) bt = portal_templates.download(bt5_id)
bt.install() bt.install()
LOG("Wizard", INFO, LOG("Wizard", INFO,
"[OK] standard bt5 installation (HTTP) from %s" %bt5_id) "[OK] standard bt5 installation (HTTP) from %s" %bt5_id)
else: else:
## remote system supplied file content ## remote system supplied file content
if install_customer_bt5: if install_customer_bt5:
bt5_filedata = bt5_files[counter] bt5_filedata = bt5_files[counter]
self._importBT5FileData(bt5_id, bt5_filedata) self._importBT5FileData(bt5_id, bt5_filedata)
LOG("Wizard", INFO, LOG("Wizard", INFO,
"[OK] customized bt5 installation (XML-RPC) %s, %s bytes" %(bt5_id,len(bt5_filedata))) "[OK] customized bt5 installation (XML-RPC) %s, %s bytes" %
(bt5_id, len(bt5_filedata)))
## .. ## ..
counter += 1 counter += 1
## can we execute after setup script that will finish installation on client side? ## can we execute after setup script that will finish installation on client side?
bt5_after_setup_script_id = server_response["server_buffer"].get("after_setup_script_id", None) bt5_after_setup_script_id = server_response["server_buffer"].get("after_setup_script_id", None)
if bt5_after_setup_script_id is None and \ if bt5_after_setup_script_id is None and \
self.getExpressConfigurationPreference('preferred_express_configuration_status', False): self.getExpressConfigurationPreference(
'preferred_express_configuration_status', False):
## we already have stored after setup script id ## we already have stored after setup script id
bt5_after_setup_script_id = self.getExpressConfigurationPreference('preferred_express_after_setup_script_id', None) bt5_after_setup_script_id = self.getExpressConfigurationPreference(
'preferred_express_after_setup_script_id', None)
if execute_after_setup_script and bt5_after_setup_script_id is not None: if execute_after_setup_script and bt5_after_setup_script_id is not None:
## Execute script provided (if) in customer specific business template. ## Execute script provided (if) in customer specific business template.
...@@ -437,14 +442,14 @@ class WizardTool(BaseTool): ...@@ -437,14 +442,14 @@ class WizardTool(BaseTool):
LOG("Wizard", INFO,"[OK] execution of afer setup script %s (for bt5 %s)\n%s" LOG("Wizard", INFO,"[OK] execution of afer setup script %s (for bt5 %s)\n%s"
%(after_script.getId(), bt5_customer_template_id, after_script_result)) %(after_script.getId(), bt5_customer_template_id, after_script_result))
## mark this ERP5 instance as configured ## mark this ERP5 instance as configured
self.setExpressConfigurationPreference('preferred_express_configuration_status', self.setExpressConfigurationPreference(
1) 'preferred_express_configuration_status', 1)
self.setExpressConfigurationPreference('preferred_express_after_setup_script_id', self.setExpressConfigurationPreference(
bt5_after_setup_script_id) 'preferred_express_after_setup_script_id', bt5_after_setup_script_id)
# Make sure that the site status is reloaded. # Make sure that the site status is reloaded.
portal.portal_caches.clearAllCache() portal.portal_caches.clearAllCache()
LOG("Wizard", INFO, LOG("Wizard", INFO,
"Completed installation for %s" %' '.join(bt5_filenames)) "Completed installation for %s" %' '.join(bt5_filenames))
if use_super_manager: if use_super_manager:
noSecurityManager() noSecurityManager()
...@@ -473,10 +478,10 @@ class WizardTool(BaseTool): ...@@ -473,10 +478,10 @@ class WizardTool(BaseTool):
## selection of working business configuration ## selection of working business configuration
if response.get('server_buffer', None) is not None: if response.get('server_buffer', None) is not None:
client_id = response['server_buffer'].get('client_id', None) client_id = response['server_buffer'].get('client_id', None)
self._setServerInfo(user_id = user_id, self._setServerInfo(user_id=user_id,
password = password, password=password,
client_id = client_id) client_id=client_id)
return self.WizardTool_dialogForm(form_html = response["data"]) return self.WizardTool_dialogForm(form_html=response["data"])
elif command == "next": elif command == "next":
self._setServerInfo(user_id=user_id, \ self._setServerInfo(user_id=user_id, \
password=password, \ password=password, \
...@@ -501,8 +506,8 @@ class WizardTool(BaseTool): ...@@ -501,8 +506,8 @@ class WizardTool(BaseTool):
command = response["command"] command = response["command"]
html = response["data"] html = response["data"]
if command == "show": if command == "show":
return self.WizardTool_dialogForm(previous = response['previous'], \ return self.WizardTool_dialogForm(previous=response['previous'],
form_html = html, \ form_html=html,
next = response['next']) next = response['next'])
elif command == "update": elif command == "update":
return self.next(REQUEST=REQUEST) return self.next(REQUEST=REQUEST)
...@@ -519,15 +524,17 @@ class WizardTool(BaseTool): ...@@ -519,15 +524,17 @@ class WizardTool(BaseTool):
command = response["command"] command = response["command"]
html = response['data'] html = response['data']
if command == "show": if command == "show":
return self.WizardTool_dialogForm(previous = response['previous'], \ return self.WizardTool_dialogForm(previous=response['previous'],
form_html = html, \ form_html=html,
next = response['next']) next=response['next'])
elif command == "login": elif command == "login":
REQUEST.set('portal_status_message', html) REQUEST.set('portal_status_message', html)
return self.view(REQUEST=REQUEST) return self.view(REQUEST=REQUEST)
security.declarePublic(Permissions.AccessContentsInformation, 'getInstallationStatusReportFromClient') security.declarePublic(Permissions.AccessContentsInformation,
def getInstallationStatusReportFromClient(self, active_process_id=None, REQUEST=None): 'getInstallationStatusReportFromClient')
def getInstallationStatusReportFromClient(self,
active_process_id=None, REQUEST=None):
""" Query local ERP5 instance for installation status. """ Query local ERP5 instance for installation status.
If installation is over the installation activities and reindexing If installation is over the installation activities and reindexing
activities should not exists. activities should not exists.
...@@ -579,26 +586,26 @@ class WizardTool(BaseTool): ...@@ -579,26 +586,26 @@ class WizardTool(BaseTool):
self._setServerInfo(current_bc_index = current_bc_index) self._setServerInfo(current_bc_index = current_bc_index)
self.installBT5FilesFromServer(server_response, True) self.installBT5FilesFromServer(server_response, True)
server_response = self._callRemoteMethod('finalizeInstallation', server_url) server_response = self._callRemoteMethod('finalizeInstallation', server_url)
LOG("Wizard", INFO, LOG("Wizard", INFO,
"Successfuly installed generated business configuration from %s" %self.getServerUrl()) "Successfuly installed generated business configuration from %s" %self.getServerUrl())
security.declareProtected(Permissions.ModifyPortalContent, 'repair') security.declareProtected(Permissions.ModifyPortalContent, 'repair')
def repair(self): def repair(self):
""" Repair broken ERP5 instance. This will install all business templates """ Repair broken ERP5 instance. This will install all business templates
for ERP5 instance as specified in its business configuration. """ for ERP5 instance as specified in its business configuration. """
self.REQUEST.form['wizard_request_type'] = 'repair' self.REQUEST.form['wizard_request_type'] = 'repair'
server_response = self._callRemoteMethod('getBT5FilesForBusinessConfiguration') server_response = self._callRemoteMethod('getBT5FilesForBusinessConfiguration')
if server_response['command'] == "install": if server_response['command'] == "install":
active_process = self.portal_activities.newActiveProcess() active_process = self.portal_activities.newActiveProcess()
self.activate(active_process=active_process).installBT5FilesFromServer(server_response, True) self.activate(active_process=active_process).installBT5FilesFromServer(server_response, True)
html = server_response['data'] html = server_response['data']
LOG("Wizard", INFO, LOG("Wizard", INFO,
"Start repair process for ERP5 instance from %s" %self.getServerUrl()) "Start repair process for ERP5 instance from %s" %self.getServerUrl())
return self.WizardTool_dialogForm(form_html = html) return self.WizardTool_dialogForm(form_html = html)
security.declareProtected(Permissions.ModifyPortalContent, 'update') security.declareProtected(Permissions.ModifyPortalContent, 'update')
def update(self): def update(self):
""" Update ERP5's instance standard business templates. """ """ Update ERP5's instance standard business templates. """
self.REQUEST.form['wizard_request_type'] = 'update' self.REQUEST.form['wizard_request_type'] = 'update'
server_response = self._callRemoteMethod('getBT5FilesForBusinessConfiguration') server_response = self._callRemoteMethod('getBT5FilesForBusinessConfiguration')
if server_response['command'] == "install": if server_response['command'] == "install":
...@@ -606,7 +613,7 @@ class WizardTool(BaseTool): ...@@ -606,7 +613,7 @@ class WizardTool(BaseTool):
self.activate(active_process=active_process).installBT5FilesFromServer(server_response, self.activate(active_process=active_process).installBT5FilesFromServer(server_response,
execute_after_setup_script = False) execute_after_setup_script = False)
html = server_response['data'] html = server_response['data']
LOG("Wizard", INFO, LOG("Wizard", INFO,
"Start update process for ERP5 instance from %s" %self.getServerUrl()) "Start update process for ERP5 instance from %s" %self.getServerUrl())
return self.WizardTool_dialogForm(form_html = html) return self.WizardTool_dialogForm(form_html = html)
...@@ -629,4 +636,4 @@ class WizardTool(BaseTool): ...@@ -629,4 +636,4 @@ class WizardTool(BaseTool):
""" Set Express configuration preference """ """ Set Express configuration preference """
portal_preferences = getToolByName(self, 'portal_preferences') portal_preferences = getToolByName(self, 'portal_preferences')
if portal_preferences.getActivePreference() is not None: if portal_preferences.getActivePreference() is not None:
portal_preferences.setPreference(preference_id, value) portal_preferences.setPreference(preference_id, value)
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