From a0bec7ab4d550af9eda1da6ce5fac862b54972ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Tue, 16 Oct 2012 17:34:36 +0200 Subject: [PATCH] Add scripts to migrate wrong computer titles. --- ...5Site_initiationComputerTitleMigration.xml | 72 +++++++++++++++++ .../Person_migrateComputerTitle.xml | 79 +++++++++++++++++++ master/bt5/vifib_upgrader/bt/revision | 2 +- 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/ERP5Site_initiationComputerTitleMigration.xml create mode 100644 master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/Person_migrateComputerTitle.xml diff --git a/master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/ERP5Site_initiationComputerTitleMigration.xml b/master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/ERP5Site_initiationComputerTitleMigration.xml new file mode 100644 index 000000000..1c7b17286 --- /dev/null +++ b/master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/ERP5Site_initiationComputerTitleMigration.xml @@ -0,0 +1,72 @@ +<?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.portal_catalog.searchAndActivate(\n + portal_type=\'Person\',\n + method_id=\'Person_migrateComputerTitle\'\n +)\n +\n +return \'Initiated computer title unicity migration.\'\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>ERP5Site_initiationComputerTitleMigration</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/Person_migrateComputerTitle.xml b/master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/Person_migrateComputerTitle.xml new file mode 100644 index 000000000..042c968f0 --- /dev/null +++ b/master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/Person_migrateComputerTitle.xml @@ -0,0 +1,79 @@ +<?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[ + +assert context.getPortalType() == \'Person\'\n +\n +current_dict = {}\n +\n +for computer in context.portal_catalog(portal_type=\'Computer\', default_source_administration_uid=context.getUid()):\n + title = computer.getTitle()\n + current = current_dict[title] = current_dict.get(title, 0) + 1\n + if current > 1:\n + computer.setTitle(\'%s-%s\' % (title, current))\n + + +]]></string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Person_migrateComputerTitle</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_upgrader/bt/revision b/master/bt5/vifib_upgrader/bt/revision index 4b9bce482..d7019ae2e 100644 --- a/master/bt5/vifib_upgrader/bt/revision +++ b/master/bt5/vifib_upgrader/bt/revision @@ -1 +1 @@ -148 \ No newline at end of file +149 \ No newline at end of file -- 2.30.9