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,9 +839,15 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -839,9 +839,15 @@ class ObjectTemplateItem(BaseTemplateItem):
new_io.close() new_io.close()
old_io.close() old_io.close()
if new_obj_xml != old_obj_xml: if new_obj_xml != old_obj_xml:
if context.isKeepObject(path):
modified_object_list[path] = 'Modified but should be kept', type_name
else:
modified_object_list[path] = 'Modified', type_name modified_object_list[path] = 'Modified', type_name
# get removed object # get removed object
for path in set(installed_item._objects) - set(self._objects): for path in set(installed_item._objects) - set(self._objects):
if context.isKeepObject(path):
modified_object_list[path] = 'Removed but should be kept', type_name
else:
modified_object_list[path] = 'Removed', type_name modified_object_list[path] = 'Removed', type_name
return modified_object_list return modified_object_list
...@@ -966,6 +972,10 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -966,6 +972,10 @@ class ObjectTemplateItem(BaseTemplateItem):
action = update_dict[path] action = update_dict[path]
if action == 'nothing': if action == 'nothing':
continue continue
elif context.isKeepObject(path):
# do nothing if the object is specified in keep list in
# force mode.
continue
# get subobjects in path # get subobjects in path
path_list = path.split('/') path_list = path.split('/')
container_path = path_list[:-1] container_path = path_list[:-1]
...@@ -993,6 +1003,7 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -993,6 +1003,7 @@ class ObjectTemplateItem(BaseTemplateItem):
saved_uid_dict = {} saved_uid_dict = {}
subobjects_dict = {} subobjects_dict = {}
portal_type_dict = {} portal_type_dict = {}
workflow_history = None
old_obj = container._getOb(object_id, None) old_obj = container._getOb(object_id, None)
object_existed = old_obj is not None object_existed = old_obj is not None
if old_obj is not None: if old_obj is not None:
...@@ -1015,6 +1026,11 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -1015,6 +1026,11 @@ class ObjectTemplateItem(BaseTemplateItem):
portal_type_dict[attr] = getattr(old_obj, attr, ()) portal_type_dict[attr] = getattr(old_obj, attr, ())
portal_type_dict['workflow_chain'] = \ portal_type_dict['workflow_chain'] = \
getChainByType(context)[1].get('chain_' + object_id, '') 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]) container.manage_delObjects([object_id])
# install object # install object
...@@ -1093,6 +1109,9 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -1093,6 +1109,9 @@ class ObjectTemplateItem(BaseTemplateItem):
# an object which cannot (e.g. External Method). # an object which cannot (e.g. External Method).
LOG('BusinessTemplate', WARNING, LOG('BusinessTemplate', WARNING,
'could not restore %r in %r' % (subobject_id, obj)) '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',): if obj.meta_type in ('Z SQL Method',):
fixZSQLMethod(portal, obj) fixZSQLMethod(portal, obj)
# portal transforms specific initialization # portal transforms specific initialization
...@@ -5044,6 +5063,30 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5044,6 +5063,30 @@ Business Template is a set of definitions, such as skins, portal types and categ
""" """
return self._getOrderedList('template_tool_id') 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') security.declareProtected(Permissions.ManagePortal, 'export')
def export(self, path=None, local=0, **kw): def export(self, path=None, local=0, **kw):
""" """
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
from Products.PythonScripts.standard import html_quote\n from Products.PythonScripts.standard import html_quote\n
\n \n
if brain.object_state == \'Modified\':\n if brain.object_state.startswith(\'Modified\'):\n
target_object = brain.getObject()\n target_object = brain.getObject()\n
parent_absolute_path = target_object.aq_parent.absolute_url()\n parent_absolute_path = target_object.aq_parent.absolute_url()\n
if hasattr(brain, \'bt1\'):\n if hasattr(brain, \'bt1\'):\n
......
...@@ -99,12 +99,12 @@ for object_id in keys:\n ...@@ -99,12 +99,12 @@ for object_id in keys:\n
line = newTempBase(context, \'tmp_install_%s\' %(str(i)))\n line = newTempBase(context, \'tmp_install_%s\' %(str(i)))\n
if object_state == \'New\':\n if object_state == \'New\':\n
choice_item_list=[[install_title, \'install\']]\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 if object_class in no_backup_dict:\n
choice_item_list=[[upgrade_title, \'install\']]\n choice_item_list=[[upgrade_title, \'install\']]\n
else:\n else:\n
choice_item_list=[[backup_title, \'backup\']]\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 if object_class in no_backup_dict:\n
choice_item_list=[[remove_title, \'remove\']]\n choice_item_list=[[remove_title, \'remove\']]\n
else:\n else:\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LinesField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_template_keep_path_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>line_too_long</string> </key>
<value> <string>A line was too long.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>You entered too many characters.</string> </value>
</item>
<item>
<key> <string>too_many_lines</string> </key>
<value> <string>You entered too many lines.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>10</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Paths of objects that should be kept</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string encoding="cdata"><![CDATA[
<br/>
]]></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>80</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="LinesField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_template_keep_workflow_path_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>line_too_long</string> </key>
<value> <string>A line was too long.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>You entered too many characters.</string> </value>
</item>
<item>
<key> <string>too_many_lines</string> </key>
<value> <string>You entered too many lines.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>10</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Paths of objects whose workflow histories should be kept</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string encoding="cdata"><![CDATA[
<br/>
]]></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>80</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -88,7 +88,7 @@ for diff_object in context.BusinessTemplate_getDiffObjectList():\n ...@@ -88,7 +88,7 @@ for diff_object in context.BusinessTemplate_getDiffObjectList():\n
if link == 1: \n if link == 1: \n
print \'</a>\'\n print \'</a>\'\n
print \'</div>\'\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(\'bt1\', diff_object.bt1)\n
request.set(\'bt2\', diff_object.bt2)\n request.set(\'bt2\', diff_object.bt2)\n
request.set(\'object_id\', diff_object.object_id)\n request.set(\'object_id\', diff_object.object_id)\n
......
...@@ -104,12 +104,12 @@ for bt in bt_id_list:\n ...@@ -104,12 +104,12 @@ for bt in bt_id_list:\n
object_id = bt+\'|\'+object_id\n object_id = bt+\'|\'+object_id\n
line = newTempBase(context, \'tmp_install_%s\' % i)\n line = newTempBase(context, \'tmp_install_%s\' % i)\n
\n \n
if object_state == \'Modified\':\n if object_state.startswith(\'Modified\'):\n
if object_class in no_backup_dict:\n if object_class in no_backup_dict:\n
choice_item_list = [[upgrade_title, \'install\']]\n choice_item_list = [[upgrade_title, \'install\']]\n
else:\n else:\n
choice_item_list = [[backup_title, \'backup\']]\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 if object_class in no_backup_dict:\n
choice_item_list = [[remove_title, \'remove\']]\n choice_item_list = [[remove_title, \'remove\']]\n
else:\n else:\n
......
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </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 2011-01-13 nicolas.dumazet
* add portal types for Tools bundled in erp5_core: Notification Tool was missing * add portal types for Tools bundled in erp5_core: Notification Tool was missing
......
40857 40858
\ No newline at end of file \ No newline at end of file
...@@ -211,6 +211,16 @@ class BusinessTemplate: ...@@ -211,6 +211,16 @@ class BusinessTemplate:
'type' : 'lines', 'type' : 'lines',
'mode' : 'w', 'mode' : 'w',
'default' : () }, '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', { 'id' : 'template_preference',
'description' : 'A list of preferences used by this template', 'description' : 'A list of preferences used by this template',
'type' : 'lines', '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