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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
erp5
Commits
a873ab70
Commit
a873ab70
authored
Feb 13, 2018
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CatalogTool: Simplify metatype-to-portal_type correspondance.
parent
7e810d5a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
product/ERP5Catalog/CatalogTool.py
product/ERP5Catalog/CatalogTool.py
+9
-10
No files found.
product/ERP5Catalog/CatalogTool.py
View file @
a873ab70
...
...
@@ -395,8 +395,10 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
# Get all dynamic classes from portal_type
catalog_tool_class
=
getattr
(
erp5
.
portal_type
,
'Catalog Tool'
)
catalog_class
=
getattr
(
erp5
.
portal_type
,
'Catalog'
)
sql_class
=
getattr
(
erp5
.
portal_type
,
'SQL Method'
)
script_class
=
getattr
(
erp5
.
portal_type
,
'Python Script'
)
type_conversion_dict
=
{
'Script (Python)'
:
getattr
(
erp5
.
portal_type
,
'Python Script'
),
'Z SQL Method'
:
getattr
(
erp5
.
portal_type
,
'SQL Method'
),
}
if
not
catalog_tool_class
:
LOG
(
'OldCatalogTool'
,
WARNING
,
"Portal Type Catalog Tool doesn't exist"
)
...
...
@@ -406,15 +408,12 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
for
obj
in
self
.
objectValues
():
filter_dict
=
obj
.
filter_dict
for
method
in
obj
.
objectValues
():
if
method
.
meta_type
==
'Z SQL Method'
:
new_method
=
changeObjectClass
(
obj
,
method
.
id
,
sql_class
)
elif
method
.
meta_type
==
'Script (Python)'
:
new_method
=
changeObjectClass
(
obj
,
method
.
id
,
script_class
)
else
:
LOG
(
'Catalog Migration'
,
WARNING
,
'''Subobject %s is not of meta_type
\
Z SQL Method or Script(Python)'''
%
method
.
id
)
try
:
portal_type_class
=
type_conversion_dict
[
method
.
meta_type
]
except
KeyError
:
LOG
(
'Catalog Migration'
,
WARNING
,
'%s/%s/%s has unhandled meta_type %r'
%
(
self
.
id
,
obj
.
id
,
method
.
id
,
method
.
meta_type
))
return
new_method
=
changeObjectClass
(
obj
,
method
.
id
,
portal_type_class
)
# Migrate filter_dict and keep them as properties for the methods
new_method_id
=
new_method
.
id
if
new_method_id
in
filter_dict
:
...
...
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