Commit 3d93ba52 authored by Georgios Dagkakis's avatar Georgios Dagkakis

TemplateTool: importAndReExportBusinessTemplatesFromPath renamed to...

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