Commit d013710a authored by Sebastien Robin's avatar Sebastien Robin

catalog tool: move compilation of python script inside changeObjectClass

Python script needs to be recompiled when they comes from a change of
class. This was done when business template was installing scripts, but
not when automatic migration from old catalog to new catalog was done.
So make sure to call _compile directly in changeObjectClass to make sure
Python Scripts would always work after a change of class.
parent dec831df
......@@ -3026,7 +3026,6 @@ class CatalogMethodTemplateItem(ObjectTemplateItem):
method = changeObjectClass(catalog, method_id, sql_class)
if method.meta_type == 'Script (Python)':
method = changeObjectClass(catalog, method_id, script_class)
method._compile()
new_obj = method.aq_base
self._objects[path] = new_obj
......
......@@ -45,6 +45,11 @@ def changeObjectClass(self, object_id, new_class):
i['meta_type'] = getattr(new_obj, 'meta_type', None)
break
new_obj = self._getOb(object_id, new_obj)
# Python scripts needs to be recompiled. If we need similar action on other types,
# we might later add a function "_afterClassChange" to perform different actions
# depending on the class
if hasattr(new_obj, '_compile'):
new_obj._compile()
if new_obj.isIndexable:
new_obj.reindexObject()
elif new_obj.portal_type == 'Catalog':
......
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