Commit d3fd155b authored by Aurel's avatar Aurel

remove compiled code from python script at export and recompile them

at install


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4972 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 37f9c84b
...@@ -323,6 +323,9 @@ class BaseTemplateItem(Implicit, Persistent): ...@@ -323,6 +323,9 @@ class BaseTemplateItem(Implicit, Persistent):
obj._owner = None obj._owner = None
if hasattr(aq_base(obj), 'uid'): if hasattr(aq_base(obj), 'uid'):
obj.uid = None obj.uid = None
if getattr(obj, 'meta_type', None) == 'Script (Python)':
if hasattr(aq_base(obj), '_code'):
obj._code = None
return obj return obj
class ObjectTemplateItem(BaseTemplateItem): class ObjectTemplateItem(BaseTemplateItem):
...@@ -497,6 +500,9 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -497,6 +500,9 @@ class ObjectTemplateItem(BaseTemplateItem):
container.manage_delObjects([object_id]) container.manage_delObjects([object_id])
# install object # install object
obj = self._objects[path] obj = self._objects[path]
if getattr(obj, 'meta_type', None) == 'Script (Python)':
if getattr(obj, '_code') is None:
obj._compile()
if hasattr(aq_base(obj), 'groups'): if hasattr(aq_base(obj), 'groups'):
# we must keep original order groups because they change when we add subobjects # we must keep original order groups because they change when we add subobjects
groups[path] = deepcopy(obj.groups) groups[path] = deepcopy(obj.groups)
...@@ -521,7 +527,6 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -521,7 +527,6 @@ class ObjectTemplateItem(BaseTemplateItem):
subobject = connection.importFile(subobject_data) subobject = connection.importFile(subobject_data)
if subobject_id not in obj.objectIds(): if subobject_id not in obj.objectIds():
obj._setObject(subobject_id, subobject) obj._setObject(subobject_id, subobject)
if obj.meta_type in ('Z SQL Method',): if obj.meta_type in ('Z SQL Method',):
# It is necessary to make sure that the sql connection # It is necessary to make sure that the sql connection
# in this method is valid. # in this method is valid.
...@@ -938,6 +943,9 @@ class WorkflowTemplateItem(ObjectTemplateItem): ...@@ -938,6 +943,9 @@ class WorkflowTemplateItem(ObjectTemplateItem):
self._backupObject(action, trashbin, container_path, object_id) self._backupObject(action, trashbin, container_path, object_id)
container.manage_delObjects([object_id]) container.manage_delObjects([object_id])
obj = self._objects[path] obj = self._objects[path]
if getattr(obj, 'meta_type', None) == 'Script (Python)':
if getattr(obj, '_code') is None:
obj._compile()
obj = obj._getCopy(container) obj = obj._getCopy(container)
container._setObject(object_id, obj) container._setObject(object_id, obj)
obj = container._getOb(object_id) obj = container._getOb(object_id)
......
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