Commit a37abd00 authored by Sebastien Robin's avatar Sebastien Robin

BT: enable support of "*" in paths to keep (like aa/* of aa/bb*)

* This add support of * in following fields:
  - Paths of Objects whose Workflow Histories should be Exported
  - Path of Objects whose Last Workflow History only should be Exported
* Before, only "**" was supported, like "aa/**" or "aa/bb**"
parent 8df0fb04
...@@ -5378,6 +5378,9 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5378,6 +5378,9 @@ Business Template is a set of definitions, such as skins, portal types and categ
for keep_path in keep_list: for keep_path in keep_list:
if keep_path.endswith('**') and path.startswith(keep_path[:-2]): if keep_path.endswith('**') and path.startswith(keep_path[:-2]):
return True return True
elif keep_path.endswith('*') and path.startswith(keep_path[:-1])\
and len(keep_path.split('/')) == len(path.split('/')):
return True
elif path == keep_path: elif path == keep_path:
return True return True
return False return False
......
...@@ -35,7 +35,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -35,7 +35,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Acquisition import aq_base from Acquisition import aq_base
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from App.config import getConfiguration from App.config import getConfiguration
from Products.ERP5Type.tests.Sequence import SequenceList from Products.ERP5Type.tests.Sequence import SequenceList, Sequence
from urllib import pathname2url from urllib import pathname2url
from Products.ERP5Type.Globals import PersistentMapping from Products.ERP5Type.Globals import PersistentMapping
from Products.CMFCore.Expression import Expression from Products.CMFCore.Expression import Expression
...@@ -7068,6 +7068,28 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -7068,6 +7068,28 @@ class TestBusinessTemplate(BusinessTemplateMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def testKeepVariousObjectsAndProperties(self):
sequence = Sequence()
self.stepCreateNewBusinessTemplate(sequence=sequence)
business_template = sequence.get("export_bt")
for property_id, method_id in [('template_keep_path_list', 'isKeepObject'),
('template_keep_workflow_path_list', 'isKeepWorkflowObject'),
('template_keep_last_workflow_history_only_path_list', 'isKeepWorkflowObjectLastHistoryOnly')]:
method = getattr(business_template, method_id)
self.assertEqual(False, method("aa/bb"))
business_template.setProperty(property_id, ["aa/bb"])
self.assertEqual(True, method("aa/bb"))
self.assertEqual(False, method("aa/bbcc"))
business_template.setProperty(property_id, ["aa/*"])
self.assertEqual(True, method("aa/bb"))
self.assertEqual(False, method("aa/bb/cc"))
business_template.setProperty(property_id, ["aa/b*"])
self.assertEqual(True, method("aa/bb"))
self.assertEqual(False, method("aa/bb/cc"))
self.assertEqual(False, method("aa/ca"))
business_template.setProperty(property_id, ["aa/**"])
self.assertEqual(True, method("aa/bb"))
self.assertEqual(True, method("aa/bb/cc"))
from Products.ERP5Type.Core.DocumentComponent import DocumentComponent from Products.ERP5Type.Core.DocumentComponent import DocumentComponent
......
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