Commit a4f20a91 authored by Rafael Monnerat's avatar Rafael Monnerat

Added support to upgrade object classes using upgrader signature.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36326 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 87cfbc54
...@@ -81,6 +81,9 @@ if len(context.ERP5Site_upgradePortalTypePropertySheet()) > 0: \n ...@@ -81,6 +81,9 @@ if len(context.ERP5Site_upgradePortalTypePropertySheet()) > 0: \n
if len(context.ERP5Site_upgradeSecurity()) > 0: \n if len(context.ERP5Site_upgradeSecurity()) > 0: \n
return True\n return True\n
\n \n
if len(context.ERP5Site_upgradeObjectClass()) > 0: \n
return True\n
\n
if len(context.ERP5Site_upgradeSQLCatalogFilter()) > 0: \n if len(context.ERP5Site_upgradeSQLCatalogFilter()) > 0: \n
return True\n return True\n
\n \n
......
...@@ -102,6 +102,8 @@ message_list.extend(context.ERP5Site_upgradeMySQLCharset(upgrade=1))\n ...@@ -102,6 +102,8 @@ message_list.extend(context.ERP5Site_upgradeMySQLCharset(upgrade=1))\n
\n \n
message_list.extend(context.ERP5Site_upgradeSQLCatalogFilter(upgrade=1))\n message_list.extend(context.ERP5Site_upgradeSQLCatalogFilter(upgrade=1))\n
\n \n
message_list.extend(context.ERP5Site_upgradeObjectClass(upgrade=1))\n
\n
# Verify if there was any change previously and \n # Verify if there was any change previously and \n
if len(message_list) > 0:\n if len(message_list) > 0:\n
message_list.extend(context.ERP5Site_upgradeSQLCatalog(upgrade=1))\n message_list.extend(context.ERP5Site_upgradeSQLCatalog(upgrade=1))\n
......
...@@ -53,7 +53,9 @@ ...@@ -53,7 +53,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string encoding="cdata"><![CDATA[
"""\n
The release signature is a kind of declarative\n The release signature is a kind of declarative\n
specification of an upgrader.\n specification of an upgrader.\n
"""\n """\n
...@@ -111,7 +113,6 @@ UPGRADABLE_BT5_ID_LIST = (\n ...@@ -111,7 +113,6 @@ UPGRADABLE_BT5_ID_LIST = (\n
"erp5_mobile",\n "erp5_mobile",\n
"erp5_ui_test_core",\n "erp5_ui_test_core",\n
"erp5_ui_test",\n "erp5_ui_test",\n
"erp5_express_ui_test",\n
)\n )\n
\n \n
# A list bt5 which are required for the upgrade\n # A list bt5 which are required for the upgrade\n
...@@ -382,7 +383,8 @@ UPDATE_ROLE_PORTAL_TYPE_LIST = [ \'Person Module\',\n ...@@ -382,7 +383,8 @@ UPDATE_ROLE_PORTAL_TYPE_LIST = [ \'Person Module\',\n
\'Sale Trade Condition\',\n \'Sale Trade Condition\',\n
\'Gadget\',\n \'Gadget\',\n
\'Knowledge Pad\',\n \'Knowledge Pad\',\n
\'Knowledge Box\' \n \'Knowledge Box\', \n
\'Currency Exchange Line\'\n
]\n ]\n
\n \n
# A property sheet expected to found into a Portal Type List.\n # A property sheet expected to found into a Portal Type List.\n
...@@ -394,6 +396,14 @@ KEEP_ORIGINAL_DICT = {\n ...@@ -394,6 +396,14 @@ KEEP_ORIGINAL_DICT = {\n
\'erp5_core\':(\'portal_preferences/default_site_preference\',\n \'erp5_core\':(\'portal_preferences/default_site_preference\',\n
\'portal_categories/function\',\n \'portal_categories/function\',\n
),\n ),\n
\n
\'erp5_dms\':(\'portal_workflow/processing_status_workflow\',\n
\'portal_categories/contributor\',\n
\'portal_skins/erp5_dms/Image_view/image_view\'\n
),\n
\n
\'erp5_base\':(\'portal_categories/specialise\',\n
),\n
\n \n
\'erp5_trade\':(\'portal_workflow/delivery_tax_interaction_workflow\',\n \'erp5_trade\':(\'portal_workflow/delivery_tax_interaction_workflow\',\n
\'portal_workflow/tax_interaction_workflow\',\n \'portal_workflow/tax_interaction_workflow\',\n
...@@ -413,11 +423,6 @@ KEEP_ORIGINAL_DICT = {\n ...@@ -413,11 +423,6 @@ KEEP_ORIGINAL_DICT = {\n
\n \n
\'erp5_wizard\':(\'portal_preferences/erp5_express_default_customer_preference\',\n \'erp5_wizard\':(\'portal_preferences/erp5_express_default_customer_preference\',\n
),\n ),\n
\n
\'erp5_express_ui_test\':(\'portal_type_roles/Person Module\',\n
\'portal_type_roles/Person\',\n
\'portal_type_roles/Organisation Module\',\n
),\n
\n \n
}\n }\n
\n \n
...@@ -458,6 +463,11 @@ VALIDATION_DICT = {\n ...@@ -458,6 +463,11 @@ VALIDATION_DICT = {\n
),\n ),\n
}\n }\n
\n \n
#\n
# Dictionary the expected filters for catalog. This is a usually determinated\n
# by catalog.getFilterDict()\n
#\n
\n
CATALOG_FILTER_DICT = { \n CATALOG_FILTER_DICT = { \n
\'z_catalog_item_list\' : \'python: here.providesIMovement()\',\n \'z_catalog_item_list\' : \'python: here.providesIMovement()\',\n
\'z_catalog_predicate_category_list\': \'python: isPredicate\',\n \'z_catalog_predicate_category_list\': \'python: isPredicate\',\n
...@@ -479,16 +489,42 @@ CATALOG_FILTER_DICT = { \n ...@@ -479,16 +489,42 @@ CATALOG_FILTER_DICT = { \n
\'z_catalog_quantity_unit_conversion_list\': \'python: here.getPortalType() in here.getPortalResourceTypeList()\',\n \'z_catalog_quantity_unit_conversion_list\': \'python: here.getPortalType() in here.getPortalResourceTypeList()\',\n
\'z0_uncatalog_inventory_stock\': \'python: isInventoryMovement\'}\n \'z0_uncatalog_inventory_stock\': \'python: isInventoryMovement\'}\n
\n \n
\n
#\n
# List of Scripts to be run after upgrade is finished to determinate \n
# the integrity and consistency of the instance.\n
#\n
\n
INTEGRITY_VERIFICATION_SCRIPT_ID_LIST = (\'ERP5Site_verifyUpgradeIntegrity\',\n INTEGRITY_VERIFICATION_SCRIPT_ID_LIST = (\'ERP5Site_verifyUpgradeIntegrity\',\n
\'ERP5Site_verifyBT5UpgradeIntegrity\',\n \'ERP5Site_verifyBT5UpgradeIntegrity\',\n
\'ERP5Site_verifyUserAuthentificationIntegrity\',\n
\'ERP5Site_verifyMemcachedIntegrity\',\n \'ERP5Site_verifyMemcachedIntegrity\',\n
\'ERP5Site_verifySQLCatalogFilterIntegrity\',\n \'ERP5Site_verifySQLCatalogFilterIntegrity\',\n
\'ERP5Site_verifyActivityIntegrity\')\n \'ERP5Site_verifyActivityIntegrity\')\n
\n \n
# \n
# Define the property and value ({\'property\' : \'value\', ...} to be set or created \n
# into erp5 portal object.\n
#\n
ERP5_SITE_PROPERTY_DICT = {}\n ERP5_SITE_PROPERTY_DICT = {}\n
\n \n
\n \n
#\n
# Define instructions for migrate object class of a group of objects like:\n
# (( relative_url <- Folder Relative URL where the object is located.\n
# , \'script_to_run_before\' <- Script ID that will test if the \n
# object can be migrated or not.\n
# , \'Products.ERP5Type.Document.FROM.CLASS\' <- Expected Class to be migrated\n
# , \'Products.ERP5Type.Document.TO.CLASS\' <- Class to be Migrated.\n
# , \'script_to_run_after\' <- Script ID that will run after test it finished.\n
# ), )\n
# \n
\n
UPGRADE_OBJECT_CLASS_LIST = ( (\'portal_gadgets\', \n
\'ERP5Site_testUpgradeObjectClass\',\n
\'Products.ERP5Type.Document.Folder.Folder\', \n
\'Products.ERP5Type.Document.Gadget.Gadget\', \n
\'ERP5Site_testUpgradeObjectClass\' ), )\n
\n
# Wrap everything into a dict\n # Wrap everything into a dict\n
signature_dict = {\n signature_dict = {\n
# Defines the default release for bt5\n # Defines the default release for bt5\n
...@@ -525,13 +561,17 @@ signature_dict = {\n ...@@ -525,13 +561,17 @@ signature_dict = {\n
, \'portal_type_property_sheet_list\' : PORTAL_TYPE_PROPERTY_SHEET_LIST\n , \'portal_type_property_sheet_list\' : PORTAL_TYPE_PROPERTY_SHEET_LIST\n
# Provide a list of Properties Expected at ERP5Site portal\n # Provide a list of Properties Expected at ERP5Site portal\n
, \'erp5_site_property_dict\' : ERP5_SITE_PROPERTY_DICT\n , \'erp5_site_property_dict\' : ERP5_SITE_PROPERTY_DICT\n
# Provide a list of tuples with informations to upgrade object class\n
, \'upgrade_object_class_list\' : UPGRADE_OBJECT_CLASS_LIST\n
}\n }\n
\n \n
if item is not None:\n if item is not None:\n
return signature_dict.get(item)\n return signature_dict.get(item)\n
else:\n else:\n
return signature_dict\n return signature_dict\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -589,6 +629,7 @@ else:\n ...@@ -589,6 +629,7 @@ else:\n
<string>CATALOG_FILTER_DICT</string> <string>CATALOG_FILTER_DICT</string>
<string>INTEGRITY_VERIFICATION_SCRIPT_ID_LIST</string> <string>INTEGRITY_VERIFICATION_SCRIPT_ID_LIST</string>
<string>ERP5_SITE_PROPERTY_DICT</string> <string>ERP5_SITE_PROPERTY_DICT</string>
<string>UPGRADE_OBJECT_CLASS_LIST</string>
<string>signature_dict</string> <string>signature_dict</string>
</tuple> </tuple>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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
Dummy script used by Upgrader Script\n
"""\n
return [ (upgrade_object.getRelativeUrl(), upgrade_object.getMetaType()) ]\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade_object</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>upgrade_object</string>
<string>_getattr_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_testUpgradeObjectClass</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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
Migrate Object Classes based on upgrade signature\n
"""\n
class_signature_list = context.ERP5Site_getUpgraderSignature(\'upgrade_object_class_list\')\n
\n
portal = context.getPortalObject()\n
message_list = []\n
\n
test_only = not upgrade\n
\n
for object_class in class_signature_list:\n
folder, test_before , from_class, to_class , test_after = object_class\n
folder_object = portal.restrictedTraverse(folder)\n
test_before_method = getattr(context, test_before )\n
test_after_method = getattr(context, test_after )\n
result = folder_object.upgradeObjectClass(test_before_method, \n
from_class, \n
to_class, \n
test_after_method, \n
test_only)\n
message_list.extend(result)\n
\n
return message_list\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>upgrade=0</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>upgrade</string>
<string>_getattr_</string>
<string>context</string>
<string>class_signature_list</string>
<string>portal</string>
<string>message_list</string>
<string>test_only</string>
<string>_getiter_</string>
<string>object_class</string>
<string>folder</string>
<string>test_before</string>
<string>from_class</string>
<string>to_class</string>
<string>test_after</string>
<string>folder_object</string>
<string>getattr</string>
<string>test_before_method</string>
<string>test_after_method</string>
<string>result</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_upgradeObjectClass</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
522 527
\ No newline at end of file \ 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