Commit c9976aef authored by Romain Courteaud's avatar Romain Courteaud

Add a batch mode to the method importFile.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8377 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ddd6c8ce
...@@ -179,9 +179,10 @@ class TemplateTool (BaseTool): ...@@ -179,9 +179,10 @@ class TemplateTool (BaseTool):
""" """
path = business_template.getTitle() path = business_template.getTitle()
path = pathname2url(path) path = pathname2url(path)
tmpdir_path = mkdtemp() # XXX Why is it necessary to create a temporary # XXX Why is it necessary to create a temporary directory?
# directory? tmpdir_path = mkdtemp()
current_directory = os.getcwd() # XXX not thread safe # XXX not thread safe
current_directory = os.getcwd()
os.chdir(tmpdir_path) os.chdir(tmpdir_path)
export_string = business_template.export(path=path) export_string = business_template.export(path=path)
os.chdir(current_directory) os.chdir(current_directory)
...@@ -243,8 +244,7 @@ class TemplateTool (BaseTool): ...@@ -243,8 +244,7 @@ class TemplateTool (BaseTool):
tar = tarfile.open(path, 'r:gz') tar = tarfile.open(path, 'r:gz')
try: try:
# create bt object # create bt object
self.newContent(portal_type='Business Template', id=id) bt = self.newContent(portal_type='Business Template', id=id)
bt = self._getOb(id)
prop_dict = {} prop_dict = {}
for prop in bt.propertyMap(): for prop in bt.propertyMap():
prop_type = prop['type'] prop_type = prop['type']
...@@ -290,7 +290,7 @@ class TemplateTool (BaseTool): ...@@ -290,7 +290,7 @@ class TemplateTool (BaseTool):
security.declareProtected( 'Import/Export objects', 'download' ) security.declareProtected( 'Import/Export objects', 'download' )
def download(self, url, id=None, REQUEST=None): def download(self, url, id=None, REQUEST=None):
""" """
Download Business Template from url, can be file or local directory Download Business Template from url, can be file or local directory
""" """
# For backward compatibility: If REQUEST is passed, it is likely that we # For backward compatibility: If REQUEST is passed, it is likely that we
# come from the management interface. # come from the management interface.
...@@ -349,7 +349,8 @@ class TemplateTool (BaseTool): ...@@ -349,7 +349,8 @@ class TemplateTool (BaseTool):
return bt return bt
def importFile(self, import_file=None, id=None, REQUEST=None, **kw): def importFile(self, import_file=None, id=None, REQUEST=None,
batch_mode=0, **kw):
""" """
Import Business Template from one file Import Business Template from one file
""" """
...@@ -383,11 +384,14 @@ class TemplateTool (BaseTool): ...@@ -383,11 +384,14 @@ class TemplateTool (BaseTool):
bt.build(no_action=1) bt.build(no_action=1)
bt.reindexObject() bt.reindexObject()
if REQUEST is not None: if (batch_mode == 0) and \
(REQUEST is not None):
ret_url = bt.absolute_url() + '/view' ret_url = bt.absolute_url() + '/view'
psm = N_("Business+Templates+Imported+Successfully") psm = N_("Business+Templates+Imported+Successfully")
REQUEST.RESPONSE.redirect("%s?portal_status_message=%s" REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"
% (ret_url, psm)) % (ret_url, psm))
elif (batch_mode == 1):
return bt
def runUnitTestList(self, test_list=[], **kwd): def runUnitTestList(self, test_list=[], **kwd):
""" """
......
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