Commit 10506558 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* support 'Paths of objects whose workflow history should be kept' and 'Paths...

* support 'Paths of objects whose workflow history should be kept' and 'Paths of objects that should be kept' in Business Template definition.
* support more 'Removed but ...' and 'Modified but ...' cases in business template installation dialogue.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42752 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 17e96eda
......@@ -839,10 +839,16 @@ class ObjectTemplateItem(BaseTemplateItem):
new_io.close()
old_io.close()
if new_obj_xml != old_obj_xml:
modified_object_list[path] = 'Modified', type_name
if context.isKeepObject(path):
modified_object_list[path] = 'Modified but should be kept', type_name
else:
modified_object_list[path] = 'Modified', type_name
# get removed object
for path in set(installed_item._objects) - set(self._objects):
modified_object_list[path] = 'Removed', type_name
if context.isKeepObject(path):
modified_object_list[path] = 'Removed but should be kept', type_name
else:
modified_object_list[path] = 'Removed', type_name
return modified_object_list
def _backupObject(self, action, trashbin, container_path, object_id, **kw):
......@@ -966,6 +972,10 @@ class ObjectTemplateItem(BaseTemplateItem):
action = update_dict[path]
if action == 'nothing':
continue
elif context.isKeepObject(path):
# do nothing if the object is specified in keep list in
# force mode.
continue
# get subobjects in path
path_list = path.split('/')
container_path = path_list[:-1]
......@@ -993,6 +1003,7 @@ class ObjectTemplateItem(BaseTemplateItem):
saved_uid_dict = {}
subobjects_dict = {}
portal_type_dict = {}
workflow_history = None
old_obj = container._getOb(object_id, None)
object_existed = old_obj is not None
if old_obj is not None:
......@@ -1015,6 +1026,11 @@ class ObjectTemplateItem(BaseTemplateItem):
portal_type_dict[attr] = getattr(old_obj, attr, ())
portal_type_dict['workflow_chain'] = \
getChainByType(context)[1].get('chain_' + object_id, '')
# try to keep workflow history for specified objects.
workflow_history = getattr(old_obj, 'workflow_history', None)
if workflow_history is not None \
and context.isKeepWorkflowObject(path):
workflow_history = deepcopy(workflow_history)
container.manage_delObjects([object_id])
# install object
......@@ -1093,6 +1109,9 @@ class ObjectTemplateItem(BaseTemplateItem):
# an object which cannot (e.g. External Method).
LOG('BusinessTemplate', WARNING,
'could not restore %r in %r' % (subobject_id, obj))
# copy workflow history if required
if workflow_history is not None:
setattr(obj, 'workflow_history', workflow_history)
if obj.meta_type in ('Z SQL Method',):
fixZSQLMethod(portal, obj)
# portal transforms specific initialization
......@@ -5044,6 +5063,30 @@ Business Template is a set of definitions, such as skins, portal types and categ
"""
return self._getOrderedList('template_tool_id')
def isKeepObject(self, path):
"""
Return True if path is included in keep object list.
"""
keep_list = self.getTemplateKeepPathList()
for keep_path in keep_list:
if keep_path.endswith('**') and path.startswith(keep_path[:-2]):
return True
elif path == keep_path:
return True
return False
def isKeepWorkflowObject(self, path):
"""
Return True if path is included in keep workflow object list.
"""
keep_list = self.getTemplateKeepWorkflowPathList()
for keep_path in keep_list:
if keep_path.endswith('**') and path.startswith(keep_path[:-2]):
return True
elif path == keep_path:
return True
return False
security.declareProtected(Permissions.ManagePortal, 'export')
def export(self, path=None, local=0, **kw):
"""
......
......@@ -54,7 +54,7 @@
from Products.PythonScripts.standard import html_quote\n
\n
if brain.object_state == \'Modified\':\n
if brain.object_state.startswith(\'Modified\'):\n
target_object = brain.getObject()\n
parent_absolute_path = target_object.aq_parent.absolute_url()\n
if hasattr(brain, \'bt1\'):\n
......
......@@ -99,12 +99,12 @@ for object_id in keys:\n
line = newTempBase(context, \'tmp_install_%s\' %(str(i)))\n
if object_state == \'New\':\n
choice_item_list=[[install_title, \'install\']]\n
elif object_state == \'Modified\':\n
elif object_state.startswith(\'Modified\'):\n
if object_class in no_backup_dict:\n
choice_item_list=[[upgrade_title, \'install\']]\n
else:\n
choice_item_list=[[backup_title, \'backup\']]\n
elif object_state in (\'Removed\', \'Removed but used\'):\n
elif object_state.startswith(\'Removed\'):\n
if object_class in no_backup_dict:\n
choice_item_list=[[remove_title, \'remove\']]\n
else:\n
......
......@@ -253,7 +253,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:(cell.choice_item_list and cell.object_state != \'Removed but used\') and cell.choice_item_list[0][1] or []</string> </value>
<value> <string>python:(cell.choice_item_list and \' but \' not in cell.object_state) and cell.choice_item_list[0][1] or []</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -88,7 +88,7 @@ for diff_object in context.BusinessTemplate_getDiffObjectList():\n
if link == 1: \n
print \'</a>\'\n
print \'</div>\'\n
if diff_object.object_state == "Modified":\n
if diff_object.object_state.startswith(\'Modified\'):\n
request.set(\'bt1\', diff_object.bt1)\n
request.set(\'bt2\', diff_object.bt2)\n
request.set(\'object_id\', diff_object.object_id)\n
......
......@@ -104,12 +104,12 @@ for bt in bt_id_list:\n
object_id = bt+\'|\'+object_id\n
line = newTempBase(context, \'tmp_install_%s\' % i)\n
\n
if object_state == \'Modified\':\n
if object_state.startswith(\'Modified\'):\n
if object_class in no_backup_dict:\n
choice_item_list = [[upgrade_title, \'install\']]\n
else:\n
choice_item_list = [[backup_title, \'backup\']]\n
elif object_state in (\'Removed\', \'Removed but used\'):\n
elif object_state.startswith(\'Removed\'):\n
if object_class in no_backup_dict:\n
choice_item_list = [[remove_title, \'remove\']]\n
else:\n
......
......@@ -253,7 +253,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:(cell.choice_item_list and cell.object_state != \'Removed but used\') and cell.choice_item_list[0][1] or []</string> </value>
<value> <string>python:(cell.choice_item_list and \' but \' not in cell.object_state) and cell.choice_item_list[0][1] or []</string> </value>
</item>
</dictionary>
</pickle>
......
2011-01-28 Kazuhiko
* support 'Paths of objects whose workflow history should be kept' and 'Paths of objects that should be kept' in Business Template definition.
* support more 'Removed but ...' and 'Modified but ...' cases in business template installation dialogue.
2011-01-13 nicolas.dumazet
* add portal types for Tools bundled in erp5_core: Notification Tool was missing
......
40857
\ No newline at end of file
40858
\ No newline at end of file
......@@ -211,6 +211,16 @@ class BusinessTemplate:
'type' : 'lines',
'mode' : 'w',
'default' : () },
{ 'id' : 'template_keep_path',
'description' : 'A list of object paths that should be kept in installing this template',
'type' : 'lines',
'mode' : 'w',
'default' : () },
{ 'id' : 'template_keep_workflow_path',
'description' : 'A list of object paths whose workflow history should be kept in installing this template',
'type' : 'lines',
'mode' : 'w',
'default' : () },
{ 'id' : 'template_preference',
'description' : 'A list of preferences used by this template',
'type' : 'lines',
......
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