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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
f8a96301
Commit
f8a96301
authored
Feb 04, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_upgrader: new feature allowing to rename categories and update objects
parent
313e8f22
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
337 additions
and
1 deletion
+337
-1
bt5/erp5_upgrader/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
...rtalTypePropertySheetTemplateItem/property_sheet_list.xml
+3
-0
bt5/erp5_upgrader/PropertySheetTemplateItem/portal_property_sheets/CategoryToolCategoryNameConstraint.xml
...al_property_sheets/CategoryToolCategoryNameConstraint.xml
+66
-0
bt5/erp5_upgrader/PropertySheetTemplateItem/portal_property_sheets/CategoryToolCategoryNameConstraint/category_name_consistency_constraint.xml
...ryNameConstraint/category_name_consistency_constraint.xml
+80
-0
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Base_getUpgradeCategoryNameList.xml
...l_skins/erp5_upgrader/Base_getUpgradeCategoryNameList.xml
+73
-0
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/CategoryTool_checkCategoryNameConsistency.xml
...p5_upgrader/CategoryTool_checkCategoryNameConsistency.xml
+112
-0
bt5/erp5_upgrader/bt/template_portal_type_property_sheet_list
...erp5_upgrader/bt/template_portal_type_property_sheet_list
+1
-0
bt5/erp5_upgrader/bt/template_property_sheet_id_list
bt5/erp5_upgrader/bt/template_property_sheet_id_list
+2
-1
No files found.
bt5/erp5_upgrader/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
View file @
f8a96301
<property_sheet_list>
<property_sheet_list>
<portal_type
id=
"Category Tool"
>
<item>
CategoryToolCategoryNameConstraint
</item>
</portal_type>
<portal_type
id=
"Template Tool"
>
<portal_type
id=
"Template Tool"
>
<item>
TemplateToolBusinessTemplateInstallationConstraint
</item>
<item>
TemplateToolBusinessTemplateInstallationConstraint
</item>
<item>
TemplateToolTableConsistencyConstraint
</item>
<item>
TemplateToolTableConsistencyConstraint
</item>
...
...
bt5/erp5_upgrader/PropertySheetTemplateItem/portal_property_sheets/CategoryToolCategoryNameConstraint.xml
0 → 100644
View file @
f8a96301
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Property Sheet"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_count
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_mt_index
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_tree
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
CategoryToolCategoryNameConstraint
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Property Sheet
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Length"
module=
"BTrees.Length"
/>
</pickle>
<pickle>
<int>
0
</int>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"OOBTree"
module=
"BTrees.OOBTree"
/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"OOBTree"
module=
"BTrees.OOBTree"
/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
bt5/erp5_upgrader/PropertySheetTemplateItem/portal_property_sheets/CategoryToolCategoryNameConstraint/category_name_consistency_constraint.xml
0 → 100644
View file @
f8a96301
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Script Constraint"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_identity_criterion
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_range_criterion
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
constraint_type/post_upgrade
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
category_name_consistency_constraint
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Script Constraint
</string>
</value>
</item>
<item>
<key>
<string>
script_id
</string>
</key>
<value>
<string>
CategoryTool_checkCategoryNameConsistency
</string>
</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/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/Base_getUpgradeCategoryNameList.xml
0 → 100644
View file @
f8a96301
<?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
This script should returns a list of tuples, each containing 2 elements \n
- The current name of the category, which was set before the upgrade\n
- The new name of the category\n
"""\n
\n
return None\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_getUpgradeCategoryNameList
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_upgrader/SkinTemplateItem/portal_skins/erp5_upgrader/CategoryTool_checkCategoryNameConsistency.xml
0 → 100644
View file @
f8a96301
<?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>
# This script is called as a "script constraint"\n
# It will replace an old category name by a new name, and update all related\n
# objects.\n
# To get the list of changes, we use the same idea as in TemplateTool_checkBusinessTemplateInstallation :\n
# we get a list of tuples containing the old names and new names from a Script (Python),\n
# which should be overriden in the custom sites\' upgraders.\n
# Because this script is called during the post-upgrade phase, we are\n
# looking for the category by its new name.\n
\n
portal = context.getPortalObject()\n
\n
error_list = []\n
\n
upgrade_list = context.Base_getUpgradeCategoryNameList()\n
\n
if not upgrade_list:\n
return []\n
\n
for old_category_name, new_category_name in upgrade_list:\n
\n
sensitive_portal_types = []\n
\n
# We gather portal types having the new category defined as a property\n
for portal_type in portal.portal_types.listTypeInfo():\n
if new_category_name in portal_type.getInstancePropertyAndBaseCategoryList():\n
sensitive_portal_types.append(portal_type.getId())\n
\n
# if sensitive_portal_types is empty, we don\'t want to check all objects\n
if fixit and sensitive_portal_types:\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_types):\n
obj = obj.getObject()\n
new_categories_list = []\n
obj_categories_list = obj.getCategoriesList()\n
for category in obj_categories_list:\n
new_category = updateRelatedCategory(category, old_category_name, new_category_name)\n
new_categories_list.append(new_category)\n
if new_categories_list != obj_categories_list:\n
obj.setCategoriesList(new_categories_list)\n
\n
for portal_type in sensitive_portal_types:\n
error_list.append(\'Portal Type %s still contains the category %s\' % (portal_type, old_category_name))\n
\n
return error_list\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
fixit=False, **kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
CategoryTool_checkCategoryNameConsistency
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_upgrader/bt/template_portal_type_property_sheet_list
View file @
f8a96301
Category Tool | CategoryToolCategoryNameConstraint
Template Tool | TemplateToolBusinessTemplateInstallationConstraint
Template Tool | TemplateToolBusinessTemplateInstallationConstraint
Template Tool | TemplateToolTableConsistencyConstraint
Template Tool | TemplateToolTableConsistencyConstraint
Template Tool | TemplateToolWorkflowChainConsistencyConstraint
Template Tool | TemplateToolWorkflowChainConsistencyConstraint
\ No newline at end of file
bt5/erp5_upgrader/bt/template_property_sheet_id_list
View file @
f8a96301
TemplateToolBusinessTemplateInstallationConstraint
TemplateToolBusinessTemplateInstallationConstraint
TemplateToolWorkflowChainConsistencyConstraint
TemplateToolWorkflowChainConsistencyConstraint
TemplateToolTableConsistencyConstraint
TemplateToolTableConsistencyConstraint
CategoryToolCategoryNameConstraint
\ No newline at end of file
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