Commit e518a093 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_upgrader: use searchAndActivate API updating objects refering to an updated category

parent 7abc6aa8
<?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
updateRelatedCategory = portal.portal_categories.updateRelatedCategory\n
\n
new_category_list = []\n
object_category_list = context.getCategoriesList()\n
\n
new_category_name = kw[\'new_category_name\']\n
old_category_name = kw[\'old_category_name\']\n
\n
for category in object_category_list:\n
new_category = updateRelatedCategory(category, old_category_name, new_category_name)\n
new_category_list.append(new_category)\n
\n
if new_category_list != object_category_list:\n
context.setCategoriesList(new_category_list)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=0, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_updateRelatedCategory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -79,18 +79,13 @@ for old_category_name, new_category_name in upgrade_list:\n
\n
# if sensitive_portal_type_list is empty, we don\'t want to check all objects\n
if fixit and sensitive_portal_type_list:\n
updateRelatedCategory = portal.portal_categories.updateRelatedCategory\n
\n
# We list objects defined by the sensitive portal types\n
for obj in portal.portal_catalog(portal_type=sensitive_portal_type_list):\n
obj = obj.getObject()\n
new_category_list = []\n
object_category_list = obj.getCategoriesList()\n
for category in object_category_list:\n
new_category = updateRelatedCategory(category, old_category_name, new_category_name)\n
new_category_list.append(new_category)\n
if new_category_list != object_category_list:\n
obj.setCategoriesList(new_category_list)\n
context.portal_catalog.searchAndActivate(\'Base_updateRelatedCategory\',\n
activate_kw=activate_kw,\n
portal_type=sensitive_portal_type_list,\n
method_kw={\'fixit\': fixit,\n
\'old_category_name\': old_category_name,\n
\'new_category_name\': new_category_name,}\n
)\n
\n
for portal_type in sensitive_portal_type_list:\n
error_list.append(\'Portal Type %s still contains the category %s\' % (portal_type, old_category_name))\n
......@@ -100,7 +95,7 @@ return error_list\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=False, **kw</string> </value>
<value> <string>fixit=False, activate_kw={}, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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