Commit b16472dd authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_upgrader: Fully drop legacy code from 2012 which is not applicable

Relevant upgraders should be reincluded as constraints.
parent 873d02e5
from Products.ERP5Type.Base import WorkflowMethod
def Instance_migrateData(self):
BLACKLIST_RELATIVE_URL_LIST = (
'software_instance_module/template_slave_instance',
'software_instance_module/template_software_instance',
'hosting_subscription_module/template_hosting_subscription',
)
@WorkflowMethod.disable
def real(self):
if self.getRelativeUrl() in BLACKLIST_RELATIVE_URL_LIST:
return
property_id = 'root_software_release_url'
if self.getPortalType() not in ('Hosting Subscription', 'Software Instance', 'Slave Instance'):
raise TypeError(self.getPortalType())
old_url = getattr(self.aq_base, property_id, None)
new_url = self.getUrlString()
if not old_url and not new_url:
raise ValueError('%s has no url defined at all' % self.getPath())
if old_url:
self.setUrlString(old_url)
assert(self.getUrlString() == old_url)
delattr(self.aq_base, property_id)
if self.getCausality() is not None:
self.setCausality(None)
if type(self) == type([]):
for o in self:
real(o[0])
else:
real(self)
def Computer_migrateCategory(self):
if self.getRelativeUrl() == 'computer_module/template_computer':
return
portal = self.getPortalObject()
def Computer_updateDestinationSection(computer):
# copy of portal_workflow/slapos_cloud_interaction_workflow/scripts/Computer_updateDestinationSection
subject_list = computer.getSubjectList()
person_list = []
for subject in subject_list:
if subject:
person_list.extend([x.getObject() for x in portal.portal_catalog(validation_state="validated", portal_type="Person", default_email_text=subject)])
computer.edit(destination_section_value_list=person_list)
@WorkflowMethod.disable
def real(self):
sale_supply_line_list = portal.portal_catalog(portal_type='Sale Supply Line',
default_aggregate_uid=self.getUid())
assert(1 == len(sale_supply_line_list))
internal_packing_list_line = portal.portal_catalog.getResultValue(
portal_type='Internal Packing List Line',
default_aggregate_uid=self.getUid(),
sort_on=(('creation_date', 'DESC'),)
)
assert(internal_packing_list_line is not None)
sale_trade_condition = sale_supply_line_list[0].getParentValue()
self.edit(
source_administration=internal_packing_list_line.getParentValue().getSourceAdministration(),
subject_list=sale_trade_condition.getSubjectList(),
)
Computer_updateDestinationSection(self)
real(self)
def Base_updateSlapOSLocalRoles(self):
@WorkflowMethod.disable
def real(self):
self.updateLocalRolesOnSecurityGroups(reindex=False)
if type(self) == type([]):
for o in self:
real(o[0])
else:
real(self)
def delIt(container, oid):
ob = container._getOb(oid)
container._objects = tuple([i for i in container._objects if i['id'] != oid])
container._delOb(oid)
try:
ob._v__object_deleted__ = 1
except Exception:
pass
from Products.ERP5.ERP5Site import addERP5Tool
def ERP5Site_deleteVifibAccounting(self):
portal = self.getPortalObject()
delIt(portal, 'portal_simulation')
addERP5Tool(portal, 'portal_simulation', 'Simulation Tool')
module_id_list = ('accounting_module', 'internal_packing_list_module',
'open_sale_order_module', 'purchase_packing_list_module',
'sale_order_module', 'sale_packing_list_module',
'sale_trade_condition_module', 'system_event_module')
for module_id in module_id_list:
module = getattr(portal, module_id)
portal_type = module.getPortalType()
title = module.getTitle()
id_generator = module.getIdGenerator()
delIt(portal, module_id)
portal.newContent(portal_type=portal_type, title=title, id=module_id,
id_generator=id_generator)
bt5_id_list = ['slapos_accounting', 'slapos_payzen']
for bt5_id in bt5_id_list:
bt5 = [q for q in portal.portal_templates.contentValues()
if q.getTitle() == bt5_id and q.getInstallationState() == 'installed'
][0].Base_createCloneDocument(batch_mode=1)
bt5.activate().install(force=1, update_catalog=0)
return 'Done.'
def upgradeObjectClass(self, test_before, from_class, to_class, test_after,
test_only=0):
"""
Upgrade the class of all objects inside this particular folder:
test_before and test_after have to be a method with one parameter.
from_class and to_class can be classes (o.__class___) or strings like:
'Products.ERP5Type.Document.Folder.Folder'
XXX Some comments by Seb:
- it is not designed to work for modules with thousands of objects,
so it totally unusable when you have millions of objects
- it is totally unsafe. There is even such code inside :
self.manage_delObjects(id of original object)
commit()
self._setObject(new object instance)
So it is possible to definitely loose data.
- There is no proof that upgrade is really working. With such a
dangerous operation, it would be much more safer to have a proof,
something like the "fix point" after doing a synchronization. Such
checking should even be done before doing commit (like it might
be possible to export objects in the xml format used for exports
before and after, and run a diff).
"""
from zLOG import LOG, WARNING
from Acquisition import aq_base, aq_parent, aq_inner
import transaction
LOG("upgradeObjectClass: folder ", 0, self.getId())
test_list = []
def getClassFromString(a_klass):
from_module = '.'.join(a_klass.split('.')[:-1])
real_klass = a_klass.split('.')[-1]
# XXX It is possible that API Change for Python 2.6.
mod = __import__(from_module, globals(), locals(), [real_klass])
return getattr(mod, real_klass)
if isinstance(from_class, type('')):
from_class = getClassFromString(from_class)
if isinstance(to_class, type('')):
to_class = getClassFromString(to_class)
for o in self.listFolderContents():
if not test_before(o):
continue
# Make sure this sub object is not the same as object
if o.getPhysicalPath() != self.getPhysicalPath():
id = o.getId()
obase = aq_base(o)
# Check if the subobject have to also be upgraded
if hasattr(obase,'upgradeObjectClass'):
test_list += o.upgradeObjectClass(test_before=test_before, \
from_class=from_class, to_class=to_class,
test_after=test_after, test_only=test_only)
# Test if we must apply the upgrade
if test_before(o) is not None:
LOG("upgradeObjectClass: id ", 0, id)
klass = obase.__class__
LOG("upgradeObjectClass: klass ", 0 ,str(klass))
LOG("upgradeObjectClass: from_class ", 0 ,str(from_class))
if klass == from_class and not test_only:
try:
newob = to_class(obase.id)
newob.id = obase.id # This line activates obase.
except AttributeError:
newob = to_class(id)
newob.id = id
keys = obase.__dict__.keys()
for k in keys:
if k not in ('id', 'meta_type', '__class__'):
setattr(newob,k,obase.__dict__[k])
LOG("upgradeObjectClass: ",0,"Delete old object: %s" % str(id))
self.manage_delObjects(id)
LOG("upgradeObjectClass: ",0,"add new object: %s" % str(newob.id))
self._setObject(id, newob)
transaction.commit()
LOG("upgradeObjectClass: ",0,"newob.__class__: %s" % str(newob.__class__))
object_to_test = self._getOb(id)
test_list += test_after(object_to_test)
if klass == from_class and test_only:
test_list += test_after(o)
return test_list
def checkUpgradeObjectClass(self, test_method):
portal_type = self.getPortalType()
mod = __import__("erp5.portal_type", globals(), locals(), [portal_type])
new_class = getattr(mod, portal_type)
if self.__class__ == new_class:
return "Object Class for '%s' is already fixed" % portal_type
return upgradeObjectClass(self.getPortalObject(), test_method,
self.__class__, new_class, test_method)
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Extension Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>extension.erp5.SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Extension Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:165, 6: Redefining built-in \'id\' (redefined-builtin)</string>
<string>W:143, 2: Unused variable \'aq_parent\' (unused-variable)</string>
<string>W:142, 2: Unused variable \'WARNING\' (unused-variable)</string>
<string>W:143, 2: Unused variable \'aq_inner\' (unused-variable)</string>
</tuple>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</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 encoding="cdata"><![CDATA[
portal_activities = context.getPortalObject().portal_activities\n
tag = script.id\n
if bg==1 and portal_activities.countMessageWithTag(tag) > 0:\n
raise TypeError(\'Already running\')\n
\n
if bg:\n
getattr(portal_activities.activate(tag=tag), \'00_ERP5Site_postUpgradeFixUp\')(bg=0)\n
else:\n
portal_activities.ERP5Site_postUpgradeFixUpPortalDeliveries()\n
portal_activities.ERP5Site_postUpgradeFixUpPortalTemplates()\n
portal_activities.ERP5Site_postUpgradeFixUpPortalTypes()\n
portal_activities.ERP5Site_postUpgradeFixUpPortalPropertySheets()\n
portal_activities.ERP5Site_postUpgradeFixUpPortalRules()\n
portal_activities.ERP5Site_postUpgradeFixUpPortalSkins()\n
\n
return \'Done.\'\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bg=1</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>00_ERP5Site_postUpgradeFixUp</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 encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
tag = script.id\n
if portal.portal_activities.countMessageWithTag(tag) > 0:\n
raise TypeError(\'Already running\')\n
method_id = \'Instance_migrateData\'\n
for module in (\n
portal.hosting_subscription_module,\n
portal.software_instance_module,\n
):\n
module.recurseCallMethod(\n
method_id,\n
max_depth=1,\n
min_depth=1,\n
max_retry=0,\n
activate_kw={\'tag\': script.id}\n
)\n
\n
return \'Done.\'\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>01_ERP5Site_migrateInstanceData</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 encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
tag = script.id\n
if portal.portal_activities.countMessageWithTag(tag) > 0:\n
raise TypeError(\'Already running\')\n
method_id = \'Computer_migrateCategory\'\n
for module in (\n
portal.computer_module,\n
):\n
module.recurseCallMethod(\n
method_id,\n
max_depth=1,\n
min_depth=1,\n
max_retry=0,\n
activate_kw={\'tag\': script.id}\n
)\n
\n
return \'Done.\'\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>02_ERP5Site_migrateComputerCategory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>ERP5Site_deleteVifibAccounting</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>03_ERP5Site_deleteVifibAccounting</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></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>context.getPortalObject().ERP5Site_reindexAll(clear_catalog=1)\n
return \'Done.\'\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>04_ERP5Site_reindexWithClear</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 encoding="cdata"><![CDATA[
portal = context.getPortalObject()\n
\n
tag = script.id\n
if portal.portal_activities.countMessageWithTag(tag) > 0:\n
raise TypeError(\'Already running\')\n
\n
portal_type_list = []\n
for portal_type in portal.portal_types.contentValues():\n
if len(portal_type.contentValues(portal_type=\'Role Information\')) > 0:\n
portal_type_list.append(portal_type.getId())\n
\n
method_id = \'Base_updateSlapOSLocalRoles\'\n
portal.portal_catalog.searchAndActivate(\n
portal_type=portal_type_list,\n
method_id=method_id,\n
activate_kw={\'tag\': tag,}\n
)\n
return \'Done.\'\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>05_ERP5Site_updateLocalRoles</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>context.getPortalObject().ERP5Site_reindexAll(clear_catalog=1)\n
return \'Done.\'\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>06_ERP5Site_reindexWithClear</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>if obj.getId() == \'portal_tests\':\n
return obj\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>obj</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_beforeTestMethod</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>checkUpgradeObjectClass</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_checkUpgradeObjectClass</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -57,22 +57,18 @@ ...@@ -57,22 +57,18 @@
a old business template without updating it and without removing it\n a old business template without updating it and without removing it\n
"""\n """\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
portal_templates = portal.portal_templates\n
\n \n
#installed_bt5_list = [bt5.getTitle() for bt5 in portal_templates.getInstalledBusinessTemplateList()]\n bt5_update_catalog_list = (\'erp5_ingestion_mysql_innodb_catalog\',\n
available_bt5_list = [bt5 for bt5 in \n \'slapos_cloud\', \'erp5_accounting\',\n
portal_templates.getRepositoryBusinessTemplateList(newest_only=True)]\n \'erp5_movement_table_catalog\')\n
signature = portal.ERP5Site_getUpgraderSignature()\n \n
bt5_id_list = []\n bt5_id_list = bt5_update_catalog_list + (\'slapos_erp5\',)\n
for bt5_id in signature.get(\'required_bt5_id_list\', []):\n
available_bt5 = [bt5 for bt5 in available_bt5_list if bt5.title == bt5_id][0]\n
if available_bt5:\n
bt5_id_list.append(available_bt5.getTitle())\n
\n \n
keep_bt5_id_list = [\'erp5_ui_test\',\n keep_bt5_id_list = [\'erp5_ui_test\',\n
\'erp5_ui_test_core\',\n \'erp5_ui_test_core\',\n
\'slapos_category\',\n \'slapos_category\',\n
\'erp5_secure_payment\']\n \'erp5_secure_payment\']\n
\n
return bt5_id_list, keep_bt5_id_list\n return bt5_id_list, keep_bt5_id_list\n
</string> </value> </string> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>Base_updateSlapOSLocalRoles</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_updateSlapOSLocalRoles</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>Computer_migrateCategory</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_migrateCategory</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></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>"""\n
The release signature is a kind of declarative\n
specification of an upgrader.\n
"""\n
\n
\n
BEFORE_TRIGGERED_BT5_SCRIPT_ID_DICT = {\n
}\n
\n
AFTER_TRIGGERED_BT5_SCRIPT_ID_DICT = {\n
}\n
\n
ALARM_DICT = {\n
"bt5_upgrader" : True,\n
"finalize_upgrader" : True\n
}\n
\n
REQUIRED_BT5_ID_LIST = [\n
# core of core\n
\'erp5_mysql_innodb_catalog\',\n
\'erp5_full_text_myisam_catalog\',\n
\'erp5_mysql_innodb_catalog\',\n
\'erp5_core\',\n
\'erp5_property_sheets\',\n
\'erp5_xhtml_style\',\n
# erp5\n
\'erp5_workflow\',\n
\'erp5_configurator\',\n
\'erp5_base\',\n
\'erp5_administration\',\n
\'erp5_accounting\',\n
\'erp5_crm\',\n
\'erp5_accounting_l10n_fr\',\n
\'erp5_dms\',\n
\'erp5_computer_immobilisation\',\n
\'erp5_credential\',\n
\'erp5_commerce\',\n
\'erp5_pdm\',\n
\'erp5_knowledge_pad\',\n
\'erp5_forge\',\n
\'erp5_invoicing\',\n
\'erp5_ingestion\',\n
\'erp5_item\',\n
\'erp5_open_trade\',\n
\'erp5_km\',\n
\'erp5_simulation\',\n
\'erp5_trade\',\n
\'erp5_system_event\',\n
\'erp5_payzen_secure_payment\',\n
\'erp5_web\',\n
\'erp5_project\',\n
\'erp5_credential_oauth2\',\n
# new erp5 business templates\n
\'erp5_promise\',\n
\'erp5_web_shacache\',\n
\'erp5_data_set\',\n
\'erp5_web_shadir\',\n
# slapos brand\n
\'slapos_configurator\',\n
\'slapos_cache\',\n
\'slapos_cloud\',\n
\'slapos_crm\',\n
\'slapos_hypermedia\',\n
\'slapos_jio\',\n
\'slapos_slap_tool\',\n
\'slapos_category\',\n
\'slapos_rest_api_tool_portal_type\',\n
\'slapos_rest_api\',\n
\'slapos_pdm\',\n
\'slapos_accounting\',\n
\'slapos_payzen\',\n
\'slapos_web\',\n
\'slapos_erp5\',\n
]\n
\n
REINSTALLABLE_BT5_ID_LIST = ()\n
\n
# items to keep even if marked by BT5 to \'Remove\'\n
KEEP_ORIGINAL_DICT = {\n
\'erp5_secure_payment\': ( \'portal_secure_payments\', ),\n
\'slapos_cloud\': ( \'hosting_subscription_module\', \'software_installation_module\', \'software_instance_module\',\n
\'portal_types/Hosting Subscription\', \'portal_types/Hosting Subscription Module\', \'portal_types/Slave Instance\',\n
\'portal_types/Software Installation\', \'portal_types/Software Installation Module\', \'portal_types/Software Instance\',\n
\'portal_types/Software Instance Module\'),\n
\'slapos_accounting\': ( \'portal_types/Subscription Item Root Simulation Rule\', ),\n
\'slapos_payzen\': (\'portal_types/Payzen Event\', \'portal_types/Payzen Event Message\',),\n
}\n
\n
# Items which need validation at upgrade time\n
VALIDATION_DICT = { }\n
\n
INTEGRITY_VERIFICATION_SCRIPT_ID_LIST = ( )\n
\n
ALARM_TOOL_CONFIGURATION_LIST = ( )\n
\n
#WORKFLOW_CHAIN_DICT = context.getPortalObject().portal_workflow.getWorkflowChainDict()\n
#\n
#WORKFLOW_CHAIN_DICT.update(**{\n
# \'chain_Slave Instance\': \'edit_workflow, instance_accounting_slap_interaction_workflow, instance_slap_interface_workflow, item_workflow, local_permission_vifib_interaction_workflow, slap_interaction_workflow\',\n
# \'chain_Software Instance\': \'edit_workflow, instance_accounting_slap_interaction_workflow, instance_slap_interface_workflow, item_workflow, local_permission_vifib_interaction_workflow, slap_interaction_workflow\',\n
#})\n
\n
FINALIZE_ALARM_SCRIPT = ( )\n
\n
# Wrap everything into a dict\n
signature_dict = {\n
\'alarm_dict\' : ALARM_DICT\n
, \'required_bt5_id_list\': REQUIRED_BT5_ID_LIST\n
, \'before_triggered_bt5_id_dict\': BEFORE_TRIGGERED_BT5_SCRIPT_ID_DICT\n
, \'after_triggered_bt5_id_dict\': AFTER_TRIGGERED_BT5_SCRIPT_ID_DICT\n
, \'reinstalable_bt5_id_list\': REINSTALLABLE_BT5_ID_LIST\n
, \'keep_original_dict\': KEEP_ORIGINAL_DICT\n
, \'validation_dict\': VALIDATION_DICT\n
, \'integrity_verification_script_id_list\': INTEGRITY_VERIFICATION_SCRIPT_ID_LIST\n
, \'alarm_tool_configuration_list\' : ALARM_TOOL_CONFIGURATION_LIST\n
# , \'workflow_chain_dict\': WORKFLOW_CHAIN_DICT\n
# , \'finalize_upgrade_script_list\': FINALIZE_ALARM_SCRIPT\n
}\n
\n
if item is not None:\n
return signature_dict.get(item, None)\n
else:\n
return signature_dict\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>item=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getUpgraderSignature</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>portal = context.getPortalObject()\n
\n
portal_classes = getattr(portal, \'portal_classes\', None)\n
if portal_classes:\n
portal.manage_delObjects([\'portal_classes\'])\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeFixUpPortalClasses</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>portal_deliveries = context.getPortalObject().portal_deliveries\n
for builder_id in [\n
\'purchase_invoice_tax_builder\',\n
\'sale_invoice_tax_builder\',\n
]:\n
if builder_id in portal_deliveries.objectIds():\n
portal_deliveries.deleteContent(builder_id)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeFixUpPortalDeliveries</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 encoding="cdata"><![CDATA[
portal_property_sheets = context.getPortalObject().portal_property_sheets\n
\n
id_list = portal_property_sheets.objectIds()\n
\n
unwanted_id_list = [\n
\'FreeFiberRequest\', \'VifibAssignmentConstraint\',\n
\'VifibCapacity\', \'VifibComputerConstraint\',\n
\'VifibComputerPartitionConstraint\',\n
\'VifibEmailConstraint\', \'VifibHostingSubscriptionConstraint\',\n
\'VifibInternalPackingListConstraint\', \'VifibInternalPackingListLineConstraint\',\n
\'VifibOpenSaleOrderConstraint\', \'VifibOpenSaleOrderLineConstraint\',\n
\'VifibPersonConstraint\', \'VifibPurchasePackingListConstraint\',\n
\'VifibPurchasePackingListLineConstraint\',\n
\'VifibRestAPISystemPreference\', \'VifibSaleInvoiceConstraint\',\n
\'VifibSaleOrderConstraint\', \'VifibSaleOrderLineConstraint\',\n
\'VifibSalePackingListConstraint\', \'VifibSalePackingListLineConstraint\',\n
\'VifibSoftwareProductConstraint\', \'VifibSoftwareReleaseConstraint\',\n
\'VifibSystemPreference\'\n
]\n
to_delete_id_list = []\n
\n
for id in unwanted_id_list:\n
if id in id_list:\n
to_delete_id_list.append(id)\n
if len(to_delete_id_list) > 0:\n
portal_property_sheets.deleteContent(to_delete_id_list)\n
\n
def getPropertySheet(name):\n
return portal_property_sheets.restrictedTraverse(name)\n
\n
# fix HostingSubscription\n
if \'root_software_release_url_property\' in getPropertySheet(\'HostingSubscription\'):\n
getPropertySheet(\'HostingSubscription\').deleteContent(\'root_software_release_url_property\')\n
\n
# fix SlaveInstanceConstraint\n
for id in [\n
\'destination_reference_property_existence_constraint\',\n
\'reference_property_existence_constraint\',\n
\'setup_packing_list_constraint\',\n
\'text_content_existence_constraint\',\n
]:\n
if id in getPropertySheet(\'SlaveInstanceConstraint\'):\n
getPropertySheet(\'SlaveInstanceConstraint\').deleteContent(id)\n
\n
# fix SoftwareInstanceConstraint\n
for id in [\n
\'destination_reference_property_existence_constraint\',\n
\'reference_property_existence_constraint\', \n
\'setup_packing_list_constraint\',\n
\'ssl_certificate_constraint\',\n
\'ssl_key_constraint\',\n
]:\n
if id in getPropertySheet(\'SoftwareInstanceConstraint\'):\n
getPropertySheet(\'SoftwareInstanceConstraint\').deleteContent(id)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeFixUpPortalPropertySheets</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>portal_rules = context.getPortalObject().portal_rules\n
\n
portal_rules.fixConsistency()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeFixUpPortalRules</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>portal_skins = context.getPortalObject().portal_skins\n
for name, layers in portal_skins.getSkinPaths():\n
layer_list = layers.split(\',\')\n
if \'garbage_collection_201112\' in layer_list:\n
layer_list = [q for q in layer_list if q != \'garbage_collection_201112\']\n
portal_skins.manage_skinLayers(skinpath=layer_list, skinname=name, add_skin=1)\n
portal_skins.getPortalObject().changeSkin(None)\n
if name == \'ODS\':\n
if \'erp5_ooo_import\' not in layer_list:\n
layer_list.insert(layer_list.index(\'erp5_open_trade\'), \'erp5_ooo_import\')\n
portal_skins.manage_skinLayers(skinpath=layer_list, skinname=name, add_skin=1)\n
portal_skins.getPortalObject().changeSkin(None)\n
\n
# drop not needed custom\n
id = \'SQLBase_reserveMessageList\'\n
if id in portal_skins.custom.objectIds():\n
portal_skins.custom.manage_delObjects([id])\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeFixUpPortalSkins</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>portal_templates = context.getPortalObject().portal_templates\n
# uninstall not needed Business Templates\n
unwanted_business_template_list = [\n
\'erp5_ui_test\',\n
\'erp5_ui_test_core\',\n
\'erp5_discount_resource\',\n
\'erp5_tax_resource\',\n
\'erp5_legacy_tax_system\',\n
\'vifib_software_pdm\',\n
\'erp5_l10n_fr\', \n
]\n
\n
for bt5 in portal_templates.contentValues(portal_type=\'Business Template\'):\n
if bt5.getTitle() in unwanted_business_template_list:\n
if bt5.getInstallationState() == \'installed\':\n
bt5.uninstall()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeFixUpPortalTemplates</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>portal_types = context.getPortalObject().portal_types\n
def getPortalType(portal_type):\n
return portal_types.restrictedTraverse(portal_type)\n
\n
# fix Delivery Simulation Rule portal type\n
getPortalType(\'Delivery Simulation Rule\').setTypeAllowedContentTypeList((\n
\'Category Membership Divergence Tester\', \'DateTime Divergence Tester\',\n
\'Float Divergence Tester\', \'Net Converted Quantity Divergence Tester\',\n
\'Specialise Divergence Tester\', \'String Divergence Tester\',\n
\'Variation Divergence Tester\'\n
))\n
\n
# fix Hosting Subscription\n
getPortalType(\'Hosting Subscription\').setTypeBaseCategoryList((\n
\'destination_section\'\n
))\n
\n
# fix Item\n
getPortalType(\'Item\').setTypePropertySheetList([ ])\n
getPortalType(\'Item\').setTypeBaseCategoryList([ ])\n
\n
# fix Preference\n
# property sheets have to be removed\n
# fix Preference Tool\n
# property sheets have to be removed\n
\n
# fix Slave Instance\n
getPortalType(\'Slave Instance\').setTypeBaseCategoryList((\n
\'aggregate\', \'causality\', \'specialise\'\n
))\n
\n
# fix Software Instance\n
getPortalType(\'Software Instance\').setTypeBaseCategoryList((\n
\'aggregate\', \'causality\', \'specialise\'\n
))\n
\n
# fix Software Product\n
getPortalType(\'Software Product\').setTypePropertySheetList((\n
\'DefaultImage\', \'SlapOSSoftwareProductConstraint\'\n
))\n
getPortalType(\'Software Product\').setTypeAllowedContentTypeList((\n
\'Embedded File\', \'Purchase Supply Line\', \'Sale Supply Line\'\n
))\n
\n
# fix Types Tool\n
getPortalType(\'Types Tool\').setTypeAllowedContentTypeList((\n
\'Base Type\', \'Gadget Type\'\n
))\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeFixUpPortalTypes</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>portal = context.getPortalObject()\n
\n
# Reindex all objects in accounting module\n
folder_tag = \'reindex_module\'\n
object_tag = \'accounting\'\n
portal.accounting_module.activate(tag=folder_tag).Folder_reindexAll(\n
folder_tag=folder_tag,\n
object_tag=object_tag)\n
\n
priority = 4\n
folder_after_tag = object_tag\n
object_tag = \'sale_packing_list\'\n
object_after_tag = folder_after_tag\n
# Reindex all objects in Sale Packing List module\n
portal.sale_packing_list_module.activate(tag=folder_tag,\n
priority=priority,\n
after_tag=folder_after_tag\n
).Folder_reindexAll(\n
folder_tag=folder_tag,\n
object_tag=object_tag,\n
object_priority=priority,\n
folder_after_tag=folder_after_tag,\n
object_after_tag=object_after_tag)\n
\n
# Reindex all objects in Portal Simulation\n
folder_after_tag = (\'accounting\', \'sale_packing_list\')\n
object_tag = \'simulation\'\n
object_after_tag = folder_after_tag\n
portal.portal_simulation.activate(tag=folder_tag,\n
priority=priority,\n
after_tag=folder_after_tag\n
).Folder_reindexAll(\n
folder_tag=folder_tag,\n
object_tag=object_tag,\n
object_priority=priority,\n
folder_after_tag=folder_after_tag,\n
object_after_tag=object_after_tag)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_postUpgradeReindexObjects</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 encoding="cdata"><![CDATA[
"""\n
Check installed business templates one \n
by one. If one of the business templates does not \n
use the latest revision, then we need to install.\n
"""\n
# Initialize variables\n
portal = context.getPortalObject()\n
portal_templates = portal.portal_templates\n
signature = portal.ERP5Site_getUpgraderSignature()\n
message_list = []\n
\n
previous_bt5_id = None\n
bt5_counter = 0\n
available_bt5_list = portal_templates.getRepositoryBusinessTemplateList(newest_only=True)\n
available_bt5_id_list = [x.title for x in available_bt5_list]\n
required_bt5_id_list = signature.get(\'required_bt5_id_list\', [])\n
\n
upgradable_bt5_id_list = signature.get(\'upgradable_bt5_id_list\', [])\n
if len(upgradable_bt5_id_list) > 0:\n
raise NotImplementedError\n
\n
reinstallable_bt5_id_list = signature.get(\'reinstallable_bt5_id_list\', signature.get(\'reinstalable_bt5_id_list\', []))\n
if len(reinstallable_bt5_id_list) > 0:\n
raise NotImplementedError\n
\n
before_triggered_bt5_id_dict = signature.get(\'before_triggered_bt5_id_dict\', {})\n
after_triggered_bt5_id_dict = signature.get(\'after_triggered_bt5_id_dict\', {})\n
update_catalog_bt5_id_list = signature.get(\'update_catalog_bt5_id_list\', [])\n
if len(update_catalog_bt5_id_list) > 0:\n
raise NotImplementedError\n
\n
missing_id_list = [q for q in required_bt5_id_list if q not in available_bt5_id_list]\n
if len(missing_id_list) > 0:\n
script.log(\'Missing Business Templates: %s\' % (\', \'.join(missing_id_list),))\n
return message_list\n
\n
bt5_id_list = required_bt5_id_list\n
\n
bt5_list = []\n
for bt5_id in bt5_id_list:\n
available_bt5 = [q for q in available_bt5_list if q.title == bt5_id][0]\n
bt5_list.append(portal_templates.decodeRepositoryBusinessTemplateUid(available_bt5.uid))\n
\n
installed_bt5_title_list = [o.getTitle() for o in portal_templates.getInstalledBusinessTemplateList()]\n
\n
bt5_counter = portal_templates.countFolder()[0][0]\n
\n
def installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter, force=False):\n
bt5_id = "%s_%s" % (bt5_counter, bt5_title)\n
kw = dict(activity="SQLQueue", tag=bt5_id)\n
if previous_bt5 is not None:\n
kw[\'after_tag\'] = previous_bt5\n
# We must make sure all documents from previous installations \n
# are already indexed (specially categories).\n
kw[\'after_method_id\'] = "immediateReindexObject"\n
update_catalog = bt5_title in update_catalog_bt5_id_list\n
before_triggered_bt5_id_list = before_triggered_bt5_id_dict.get(bt5_title, ())\n
after_triggered_bt5_id_list = after_triggered_bt5_id_dict.get(bt5_title, ())\n
keep_original_list = signature.get(\'keep_original_dict\', {}).get(bt5_title, ())\n
if upgrade:\n
portal_templates.activate(**kw).updateBusinessTemplateFromUrl(\n
bt5_url, # id=bt5_id, \n
keep_original_list=keep_original_list,\n
before_triggered_bt5_id_list=before_triggered_bt5_id_list,\n
after_triggered_bt5_id_list=after_triggered_bt5_id_list,\n
update_catalog=update_catalog,\n
reinstall=force)\n
previous_bt5_id = bt5_id\n
bt5_counter += 1\n
message_list.append("%s will be installed" % bt5_url)\n
return bt5_id\n
\n
previous_bt5 = None\n
for repository, bt5_id in bt5_list:\n
new_bt = [x for x in available_bt5_list \\\n
if portal_templates.decodeRepositoryBusinessTemplateUid(x.uid) == (repository, bt5_id)][0]\n
bt5_url = \'/\'.join((repository, bt5_id))\n
bt5_title = new_bt.title\n
if bt5_title in reinstallable_bt5_id_list:\n
bt5_id = installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter, force=True)\n
previous_bt5 = bt5_id\n
else:\n
installed_bt = portal_templates.getInstalledBusinessTemplate(bt5_title, strict=True)\n
if installed_bt is not None:\n
if int(installed_bt.getRevision() or 0) >= int(new_bt.revision or 0):\n
continue\n
if bt5_title in required_bt5_id_list:\n
bt5_counter += 1\n
bt5_id = installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter)\n
previous_bt5 = bt5_id\n
elif bt5_title in installed_bt5_title_list: # update_bt5_id_list\n
bt5_counter += 1\n
bt5_id = installBT5(bt5_url, bt5_title, previous_bt5, bt5_counter)\n
previous_bt5 = bt5_id\n
\n
return message_list\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeBusinessTemplateList</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>portal = context.getPortalObject()\n
\n
return context.Base_checkUpgradeObjectClass(portal.portal_tests, context.Base_beforeTestMethod)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradePortalTestsClass</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_zFixUpgradeDatabase</string> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string>DROP PROCEDURE IF EXISTS upgrade_fix_database;\n
\n
DELIMITER //\n
\n
CREATE PROCEDURE upgrade_fix_database()\n
BEGIN\n
\n
/* Create table accounting_transaction */\n
CREATE TABLE IF NOT EXISTS `accounting_transaction` (\n
`uid` BIGINT UNSIGNED NOT NULL,\n
`order_id` TINYINT UNSIGNED NOT NULL,\n
\n
`section_uid` BIGINT UNSIGNED,\n
`mirror_section_uid` BIGINT UNSIGNED,\n
`resource_uid` BIGINT UNSIGNED,\n
\n
`project_uid` BIGINT UNSIGNED,\n
`payment_uid` BIGINT UNSIGNED,\n
\n
`accounting_transaction_title` VARCHAR(255),\n
`reference` VARCHAR(255),\n
`specific_reference` VARCHAR(255),\n
\n
`operation_date` datetime default NULL,\n
\n
`total_debit` real,\n
`total_credit` real,\n
\n
PRIMARY KEY (`uid`, `order_id`),\n
KEY (`section_uid`, `mirror_section_uid`)\n
-- TODO: keys\n
) ENGINE=InnoDB;\n
\n
/* Alter table catalog */\n
-- add a column grouping_date safely\n
IF NOT EXISTS( (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE()\n
AND COLUMN_NAME=\'grouping_date\' AND TABLE_NAME=\'catalog\') ) THEN\n
ALTER TABLE `catalog` ADD `grouping_date` datetime AFTER `grouping_reference`;\n
END IF;\n
\n
\n
/* Alter table stock */\n
-- add a column is_accountable safely\n
IF NOT EXISTS( (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE()\n
AND COLUMN_NAME=\'is_accountable\' AND TABLE_NAME=\'stock\') ) THEN\n
ALTER TABLE `stock` ADD COLUMN `is_accountable` BOOLEAN AFTER `is_cancellation`;\n
END IF;\n
\n
-- add a column explanation_uid safely\n
IF NOT EXISTS( (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE()\n
AND COLUMN_NAME=\'explanation_uid\' AND TABLE_NAME=\'stock\') ) THEN\n
ALTER TABLE `stock` ADD COLUMN `explanation_uid` BIGINT UNSIGNED AFTER `order_id`;\n
END IF;\n
\n
-- add a column funding_uid safely\n
IF NOT EXISTS( (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE()\n
AND COLUMN_NAME=\'funding_uid\' AND TABLE_NAME=\'stock\') ) THEN\n
ALTER TABLE `stock` ADD COLUMN `funding_uid` BIGINT UNSIGNED AFTER `project_uid`;\n
END IF;\n
\n
-- add a column payment_request_uid safely\n
IF NOT EXISTS( (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE()\n
AND COLUMN_NAME=\'payment_request_uid\' AND TABLE_NAME=\'stock\') ) THEN\n
ALTER TABLE `stock` ADD COLUMN `payment_request_uid` BIGINT UNSIGNED AFTER `funding_uid`;\n
END IF;\n
\n
-- Modify column order_id\n
ALTER TABLE `stock` MODIFY `order_id` BIGINT UNSIGNED;\n
\n
-- Upgrade Index\n
ALTER TABLE `stock` DROP INDEX `section_uid`, ADD INDEX `section_uid_portal_type_mirror_section_uid` (`section_uid`,`portal_type`, `mirror_section_uid`);\n
ALTER TABLE `stock` ADD INDEX `funding_uid` (`funding_uid`);\n
ALTER TABLE `stock` ADD INDEX `explanation_uid` (`explanation_uid`);\n
ALTER TABLE `stock` DROP INDEX `resource_uid`;\n
\n
END//\n
\n
DELIMITER ;\n
\n
CALL upgrade_fix_database();</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>Instance_migrateData</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>SlapOSUpgrader</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Instance_migrateData</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
extension.erp5.SlapOSUpgrader
\ No newline at end of file
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