[WIP] Do not use prefix importing objects of classes where the prefix is not used
in the export path. These classes are:
In each class the prefix is used only in preinstall both for current business template and the previously installed ones. The use of prefix in preinstall is twofold:
- To have unique keys in the dictionary of modified objects
- To preserve compatibility with old business templates
- This way we use manual prefix only in preinstall. Since it is not fully eliminated though I do not know how much it is worth to apply.
- Do you know why different classes are exported using different folder structures? I mean for example:
- PortalTypeWorkflowChainTemplateItem objects (workflow_chain_type.xml) are exported directly to the folder.
- PropertySheetTemplateItem objects are exported in a sub-folder named portal_property_sheets. The intermediate layer is always empty I think, i.e. nothing is exported directly to PropertySheetTemplateItem folder.
- I have no idea how compatibility to business templates installed with previous revision of code can be automatically tested.
678 678 synchronizeDynamicModules(portal, force=True) 679 679 gc.collect() 680 680 681 def _addPrefixToObjects(self, prefix):
PropertySheetTemplateItem objects are exported in a sub-folder named portal_property_sheets. The intermediate layer is always empty I think, i.e. nothing is exported directly to PropertySheetTemplateItem folder
This is because these objects gets installed in portal_property_sheets tools in ZODB. workflow_chain_type is not installed as an object, but just as properties of workflow tool.
I have no idea how compatibility to business templates installed with previous revision of code can be automatically tested.
If you want to test you can install a business template that was exported in an old format, you can store a business template here https://lab.nexedi.com/nexedi/erp5/tree/master/product/ERP5/tests/test_data and import it during the test. But if I understand correctly what we want to test here is a bit different, we want to test how we update a business template that was installed with old version of the business template code. I don't think we did that already. You can always install the business template and "manually" change the _objects in the installed business template so that their internal structure is as expected, but I am sure there is a better way.
Yes, I meant the latter 'test how we update a business template that was installed with old version of the business template code'. I suppose it has not been done already, because code that breaks this did not create errors/failures in the test suite. It is an idea to change the _objects manually, I will do some research on alternatives.
The unit test along with test template added in 87e1383d could be an approach. Tried the same in a branch that would produce the problem (and passed the test suite) here https://lab.nexedi.com/georgios.dagkakis/erp5/commits/remove_prefix_buggy, and the test fails in that branch. Still not sure if it would be good way though..
Still I cannot find a better way to do this and have it really tested. I am inclined not to pursue on removing prefixes more, it is a bit dirty and I found some bugs in the past (i.e. different prefix set on import and build for some types), but since we need unique keys on preinstall they have to be introduced at some point anyway. If there are no other ideas I will close this merge request for now.