Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
erp5
Commits
e518a093
Commit
e518a093
authored
Mar 02, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_upgrader: use searchAndActivate API updating objects refering to an updated category
parent
7abc6aa8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
13 deletions
+89
-13
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Base_updateRelatedCategory.xml
...portal_skins/erp5_upgrader/Base_updateRelatedCategory.xml
+81
-0
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/CategoryTool_checkCategoryNameConsistency.xml
...p5_upgrader/CategoryTool_checkCategoryNameConsistency.xml
+8
-13
No files found.
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Base_updateRelatedCategory.xml
0 → 100644
View file @
e518a093
<?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>
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/CategoryTool_checkCategoryNameConsistency.xml
View file @
e518a093
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment