Commit 3d93ba52 by Georgios Dagkakis

TemplateTool: importAndReExportBusinessTemplatesFromPath renamed to importAndReE…

…xportBusinessTemplateListFromPath
1 parent 8e466cc6
......@@ -62,7 +62,6 @@ from zLOG import LOG, INFO, WARNING
from base64 import decodestring
import subprocess
import time
from distutils.dir_util import copy_tree
WIN = os.name == 'nt'
......@@ -494,14 +493,18 @@ class TemplateTool (BaseTool):
try:
import_template.export(path=export_dir, local=True)
self._cleanUpTemplateFolder(template_path)
copy_tree(export_dir, template_path)
file_name_list = [x for x in os.listdir(export_dir)]
for file_name in file_name_list:
temp_file_path = os.path.join(export_dir, file_name)
destination_file_path = os.path.join(template_path, file_name)
shutil.move(temp_file_path, destination_file_path)
except:
raise
finally:
shutil.rmtree(export_dir)
security.declareProtected( 'Import/Export objects', 'importAndReExportBusinessTemplatesFromPath' )
def importAndReExportBusinessTemplatesFromPath(self, repository_list, REQUEST=None, **kw):
security.declareProtected( 'Import/Export objects', 'importAndReExportBusinessTemplateListFromPath' )
def importAndReExportBusinessTemplateListFromPath(self, repository_list, REQUEST=None, **kw):
"""
Migrate business templates to new format where files like .py or .html
are exported seprately than the xml.
......
......@@ -873,7 +873,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
def test_templateFolderIsCleanedUpInImportEndReexport(self):
"""
Test that when TemplateTool.importAndReExportBusinessTemplatesFromPath is
Test that when TemplateTool.importAndReExportBusinessTemplateListFromPath is
invoked the template folder is cleaned.
1. Create a bt and export it in a temporary folder
......@@ -881,7 +881,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
3. Add to the folder a sub-folder
4. Add to the sub-folder a second text file
5. Add a third file to portal_templates folder
6. Invoke TemplateTool.importAndReExportBusinessTemplatesFromPath in the
6. Invoke TemplateTool.importAndReExportBusinessTemplateListFromPath in the
template folder
7. Assert that only the template elements are present
"""
......@@ -930,8 +930,8 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
text_file_in_portal_components = open(text_file_in_sub_folder_path, "w")
text_file_in_portal_components.close()
self.assertTrue(os.path.exists(text_file_in_portal_components_path))
# invoke importAndReExportBusinessTemplatesFromPath
self.template_tool.importAndReExportBusinessTemplatesFromPath(repository_list=['/tmp'])
# invoke importAndReExportBusinessTemplateListFromPath
self.template_tool.importAndReExportBusinessTemplateListFromPath(repository_list=['/tmp'])
self.tic()
# assert that unrelated objects were deleted
self.assertFalse(os.path.exists(text_file_path))
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!