Commit e80239b1 authored by Rafael Monnerat's avatar Rafael Monnerat

Drop unsed legacy code from ERP5Configurator

 - Arbitrary remove objects and delete workflow history is bad. This code
  was never used anyway.
 - Clean up code which is not used anywhere anymore, legacy from long ago
  implementation.
parent 956e2d9c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>message</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>BusinessConfiguration_viewUnauthenticatedForm</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>GeneratorRule_setupCountries</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_empty</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Unauthenticated form</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LabelField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string encoding="cdata"><![CDATA[
<h3> You are not logged in!</h3>\n
<p> Please login from\n
<a href="">here</a>.
]]></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string encoding="cdata"><![CDATA[
&nbsp;
]]></string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Log import log\n
portal = context.getPortalObject()\n
portal_preferences = portal.portal_preferences\n
system_preference = None\n
clear_cache = 0\n
conversion_check = False\n
\n
log(conversion_server)\n
log(kumo)\n
log(memcached)\n
\n
\n
if conversion_server is not None:\n
conversion_server_address, conversion_server_port = conversion_server.split(":")\n
\n
def getActiveSystemPreference():\n
system_preference = portal_preferences.getActiveSystemPreference()\n
if system_preference is None:\n
system_preference = portal_preferences.newContent(\n
portal_type="System Preference", \n
title="Automatically Created.")\n
system_preference.enable()\n
return system_preference\n
\n
if portal_preferences.getPreferredOoodocServerAddress() != conversion_server_address:\n
system_preference = getActiveSystemPreference()\n
system_preference.setPreferredOoodocServerAddress(conversion_server_address)\n
clear_cache = 1\n
\n
if int(portal_preferences.getPreferredOoodocServerPortNumber("-1")) != int(conversion_server_port):\n
if system_preference is None:\n
system_preference = getActiveSystemPreference()\n
system_preference.setPreferredOoodocServerPortNumber(int(conversion_server_port))\n
clear_cache = 1\n
\n
if memcached is not None:\n
default_memcached_plugin = getattr(portal.portal_memcached, "default_memcached_plugin", None)\n
if default_memcached_plugin.getUrlString() != memcached:\n
default_memcached_plugin.setUrlString(memcached)\n
\n
if kumo is not None:\n
persistent_memcached_plugin = getattr(portal.portal_memcached, "persistent_memcached_plugin", None)\n
if persistent_memcached_plugin is not None:\n
if persistent_memcached_plugin.getUrlString() != kumo:\n
persistent_memcached_plugin.setUrlString(kumo)\n
\n
\n
if clear_cache:\n
portal.portal_caches.clearAllCache()\n
\n
if conversion_server is not None:\n
conversion_check = (portal_preferences.getPreferredOoodocServerAddress() == conversion_server_address) and \\\n
(int(portal_preferences.getPreferredOoodocServerPortNumber()) == int(conversion_server_port))\n
\n
return conversion_check and \\\n
default_memcached_plugin.getUrlString() == memcached and \\\n
persistent_memcached_plugin is not None and \\\n
persistent_memcached_plugin.getUrlString() == kumo\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>conversion_server=None, memcached=None, kumo=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_assertExternalServiceList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Log import log\n
portal = context.getPortalObject()\n
portal_preferences = portal.portal_preferences\n
system_preference = None\n
clear_cache = 0\n
conversion_check = False\n
\n
if conversion_server is not None:\n
conversion_server_address, conversion_server_port = conversion_server.split(":")\n
\n
def getActiveSystemPreference():\n
system_preference = portal_preferences.getActiveSystemPreference()\n
if system_preference is None:\n
system_preference = portal_preferences.newContent(\n
portal_type="System Preference", \n
title="Automatically Created.")\n
system_preference.enable()\n
return system_preference\n
\n
if portal_preferences.getPreferredOoodocServerAddress() != conversion_server_address:\n
system_preference = getActiveSystemPreference()\n
system_preference.setPreferredOoodocServerAddress(conversion_server_address)\n
clear_cache = 1\n
\n
if int(portal_preferences.getPreferredOoodocServerPortNumber()) != int(conversion_server_port):\n
if system_preference is None:\n
system_preference = getActiveSystemPreference()\n
system_preference.setPreferredOoodocServerPortNumber(int(conversion_server_port))\n
clear_cache = 1\n
\n
if memcached is not None:\n
default_memcached_plugin = getattr(portal.portal_memcached, "default_memcached_plugin", None)\n
if default_memcached_plugin.getUrlString() != memcached:\n
default_memcached_plugin.setUrlString(memcached)\n
\n
if kumo is not None:\n
persistent_memcached_plugin = getattr(portal.portal_memcached, "persistent_memcached_plugin", None)\n
if persistent_memcached_plugin is not None:\n
if persistent_memcached_plugin.getUrlString() != kumo:\n
persistent_memcached_plugin.setUrlString(kumo)\n
\n
\n
if clear_cache:\n
portal.portal_caches.clearAllCache()\n
\n
if conversion_server is not None:\n
conversion_check = (portal_preferences.getPreferredOoodocServerAddress() == conversion_server_address) and \\\n
(int(portal_preferences.getPreferredOoodocServerPortNumber()) == int(conversion_server_port))\n
\n
return conversion_check and \\\n
default_memcached_plugin.getUrlString() == memcached and \\\n
persistent_memcached_plugin is not None and \\\n
persistent_memcached_plugin.getUrlString() == kumo\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>conversion_server=None, memcached=None, kumo=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_assertExternalServiceList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
641 643
\ No newline at end of file \ No newline at end of file
...@@ -382,23 +382,3 @@ class BusinessConfiguration(Item): ...@@ -382,23 +382,3 @@ class BusinessConfiguration(Item):
if self.portal_workflow.isTransitionPossible(self, 'install'): if self.portal_workflow.isTransitionPossible(self, 'install'):
self.activate(after_tag=kw["tag"]).install() self.activate(after_tag=kw["tag"]).install()
security.declareProtected(Permissions.ModifyPortalContent, 'resetBusinessConfiguration')
def resetBusinessConfiguration(self):
"""
Reset Business Confiration at server side.
Remove all traces from user input (i.e. Configuration Saves, workflow history).
"""
object_ids = []
for obj in self.contentValues(filter={'portal_type': ['Configuration Save']}):
object_ids.append(obj.getId())
self.manage_delObjects(object_ids)
if getattr(self, "workflow_history", None) is not None:
del self.workflow_history
if getattr(self, "_global_configuration_attributes", None) is not None:
del self._global_configuration_attributes
if getattr(self, "_multi_entry_transitions", None) is not None:
del self._multi_entry_transitions
self.setSpecialiseValue(None)
# ERP5 Workflow initialization
erp5_workflow = self.getResourceValue()
...@@ -33,17 +33,11 @@ from Products.ERP5Type.Globals import DTMLFile ...@@ -33,17 +33,11 @@ from Products.ERP5Type.Globals import DTMLFile
from Products.ERP5Type.Accessor.Constant import PropertyGetter as \ from Products.ERP5Type.Accessor.Constant import PropertyGetter as \
ConstantGetter ConstantGetter
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Configurator import _dtmldir from Products.ERP5Configurator import _dtmldir
from Products.Formulator.Errors import FormValidationError from Products.Formulator.Errors import FormValidationError
import cookielib
from base64 import encodestring
from urllib import quote
from DateTime import DateTime from DateTime import DateTime
# global (RAM) cookie storage
cookiejar = cookielib.CookieJar()
referer = None referer = None
installation_status = {'bt5': {'current': 0, installation_status = {'bt5': {'current': 0,
'all': 0, }, 'all': 0, },
...@@ -53,23 +47,6 @@ installation_status = {'bt5': {'current': 0, ...@@ -53,23 +47,6 @@ installation_status = {'bt5': {'current': 0,
LANGUAGE_COOKIE_NAME = 'configurator_user_preferred_language' LANGUAGE_COOKIE_NAME = 'configurator_user_preferred_language'
BUSINESS_CONFIGURATION_COOKIE_NAME = 'business_configuration_key' BUSINESS_CONFIGURATION_COOKIE_NAME = 'business_configuration_key'
def getAvailableLanguageFromHttpAcceptLanguage(http_accept_language,
available_language_list,
default='en'):
for language_set in http_accept_language.split(','):
language_tag = language_set.split(';')[0]
language = language_tag.split('-')[0]
if language in available_language_list:
return language
return default
def _isUserAcknowledged(cookiejar):
""" Is user authenticated to remote system through a cookie. """
for cookie in cookiejar:
if cookie.name == '__ac' and cookie.value != '':
return 1
return 0
def _validateFormToRequest(form, REQUEST, **kw): def _validateFormToRequest(form, REQUEST, **kw):
""" Validate form to REQUEST. """ """ Validate form to REQUEST. """
form_kw = {} form_kw = {}
...@@ -117,29 +94,6 @@ class ConfiguratorTool(BaseTool): ...@@ -117,29 +94,6 @@ class ConfiguratorTool(BaseTool):
security.declareProtected(Permissions.ManagePortal, 'manage_overview') security.declareProtected(Permissions.ManagePortal, 'manage_overview')
manage_overview = DTMLFile('explainConfiguratorTool', _dtmldir) manage_overview = DTMLFile('explainConfiguratorTool', _dtmldir)
def getConfiguratorUserPreferredLanguage(self):
""" Get configuration language as selected by user """
REQUEST = getattr(self, 'REQUEST', None)
configurator_user_preferred_language = None
if REQUEST is not None:
# language value will be in cookie or REQUEST itself.
configurator_user_preferred_language = REQUEST.get(LANGUAGE_COOKIE_NAME,
None)
if configurator_user_preferred_language is None:
# Find a preferred language from HTTP_ACCEPT_LANGUAGE
available_language_list = [i[1] for i in self\
.ConfiguratorTool_getConfigurationLanguageList()]
configurator_user_preferred_language = \
getAvailableLanguageFromHttpAcceptLanguage(
REQUEST.get('HTTP_ACCEPT_LANGUAGE', 'en'),
available_language_list)
if configurator_user_preferred_language is None:
configurator_user_preferred_language = 'en'
return configurator_user_preferred_language
######################################################
## Navigation ##
######################################################
def login(self, REQUEST): def login(self, REQUEST):
""" Login client and show next form. """ """ Login client and show next form. """
bc = REQUEST.get('field_your_business_configuration') bc = REQUEST.get('field_your_business_configuration')
...@@ -200,8 +154,7 @@ class ConfiguratorTool(BaseTool): ...@@ -200,8 +154,7 @@ class ConfiguratorTool(BaseTool):
## client can not go further hist business configuration is already built ## client can not go further hist business configuration is already built
if business_configuration.isEndConfigurationState() or \ if business_configuration.isEndConfigurationState() or \
business_configuration.getNextTransition() == None: business_configuration.getNextTransition() == None:
return self._terminateConfigurationProcess(response, return self._terminateConfigurationProcess(response)
'no_available_transitions')
isMultiEntryTransition = business_configuration._isMultiEntryTransition() isMultiEntryTransition = business_configuration._isMultiEntryTransition()
## validate multiple forms ## validate multiple forms
...@@ -294,8 +247,7 @@ class ConfiguratorTool(BaseTool): ...@@ -294,8 +247,7 @@ class ConfiguratorTool(BaseTool):
need_validation = 0 need_validation = 0
if business_configuration.getNextTransition() == None: if business_configuration.getNextTransition() == None:
### client can not continue at the momen ### client can not continue at the momen
return self._terminateConfigurationProcess(response, return self._terminateConfigurationProcess(response)
reason='no_available_transitions')
response["previous"], html, form_title, response["next"] \ response["previous"], html, form_title, response["next"] \
= business_configuration._displayNextForm() = business_configuration._displayNextForm()
else: else:
...@@ -304,8 +256,7 @@ class ConfiguratorTool(BaseTool): ...@@ -304,8 +256,7 @@ class ConfiguratorTool(BaseTool):
business_configuration._executeTransition(form_kw=form_kw, request_kw=kw) business_configuration._executeTransition(form_kw=form_kw, request_kw=kw)
elif need_validation == 0: elif need_validation == 0:
if business_configuration.getNextTransition() == None: if business_configuration.getNextTransition() == None:
return self._terminateConfigurationProcess(response, return self._terminateConfigurationProcess(response)
'no_available_transitions')
## validation failure ## validation failure
rendered = True rendered = True
response["previous"], html, form_title, response["next"] =\ response["previous"], html, form_title, response["next"] =\
...@@ -326,18 +277,13 @@ class ConfiguratorTool(BaseTool): ...@@ -326,18 +277,13 @@ class ConfiguratorTool(BaseTool):
response.update(command = "show", data = html_data) response.update(command = "show", data = html_data)
return response return response
def _terminateConfigurationProcess(self, response, reason=''): def _terminateConfigurationProcess(self, response):
""" Terminate process and return some explanations to client why """ Terminate process and return some explanations to client why
he can no longer continue. """ he can no longer continue. """
if reason == 'no_available_transitions': response.update(command="show",
form_html = self.BusinessConfiguration_viewStopForm() next=None, \
response.update(command="show", next=None, \ previous=None,
previous=None, data=form_html) data=self.BusinessConfiguration_viewStopForm())
elif reason == 'authentification_failure':
form_html = self.BusinessConfiguration_viewUnauthenticatedForm()
response.update(command="show", data=form_html,
next=None, previous=None,)
return response return response
#security.declareProtected(Permissions.ModifyPortalContent, 'previous') #security.declareProtected(Permissions.ModifyPortalContent, 'previous')
...@@ -356,12 +302,9 @@ class ConfiguratorTool(BaseTool): ...@@ -356,12 +302,9 @@ class ConfiguratorTool(BaseTool):
def _previous(self, business_configuration, kw): def _previous(self, business_configuration, kw):
""" Returns previous form. """ """ Returns previous form. """
response = {} response = {}
## is client is not allowed access ?
if business_configuration is None:
form_html = self.BusinessConfiguration_viewUnauthenticatedForm()
return self.ConfiguratorTool_dialogForm(form_html=form_html)
## client can not go further his business configuration is already built ## client can not go further his business configuration is already built
if business_configuration.isEndConfigurationState(): if business_configuration is None or \
business_configuration.isEndConfigurationState():
form_html = self.BusinessConfiguration_viewStopForm() form_html = self.BusinessConfiguration_viewStopForm()
return self.ConfiguratorTool_dialogForm(form_html = form_html, return self.ConfiguratorTool_dialogForm(form_html = form_html,
next = "Next") next = "Next")
...@@ -410,9 +353,7 @@ class ConfiguratorTool(BaseTool): ...@@ -410,9 +353,7 @@ class ConfiguratorTool(BaseTool):
global installation_status global installation_status
# init installation status # init installation status
bt5_file_list = len(business_configuration.contentValues( installation_status['bt5']['all'] = 1
portal_types=["File", "Link"])) or 1
installation_status['bt5']['all'] = bt5_file_list
installation_status['bt5']['current'] = 0 installation_status['bt5']['current'] = 0
installation_status['activity_list'] = [] installation_status['activity_list'] = []
active_process = self.portal_activities.newActiveProcess() active_process = self.portal_activities.newActiveProcess()
......
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