Commit 03f75208 authored by Yoshinori Okuji's avatar Yoshinori Okuji

(alex) jp added the importFile function that allows to import a business template.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2055 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4924086e
...@@ -176,7 +176,6 @@ class TemplateTool (BaseTool): ...@@ -176,7 +176,6 @@ class TemplateTool (BaseTool):
""" """
from urllib import urlretrieve from urllib import urlretrieve
file, headers = urlretrieve(url) file, headers = urlretrieve(url)
if id is None: id = self.generateNewId()
self._importObjectFromFile(file, id=id) self._importObjectFromFile(file, id=id)
bt = self[id] bt = self[id]
bt.id = id # Make sure id is consistent bt.id = id # Make sure id is consistent
...@@ -187,4 +186,24 @@ class TemplateTool (BaseTool): ...@@ -187,4 +186,24 @@ class TemplateTool (BaseTool):
REQUEST.RESPONSE.redirect("%s?portal_status_message=Business+Template+Downloaded+Successfully" REQUEST.RESPONSE.redirect("%s?portal_status_message=Business+Template+Downloaded+Successfully"
% self.absolute_url()) % self.absolute_url())
def importFile(self, file, id=None, REQUEST=None):
"""
Update an existing template
"""
from tempfile import mkstemp
tempid, temppath = mkstemp()
tempfile = open(temppath, 'w')
tempfile.write(file)
tempfile.close()
self._importObjectFromFile(temppath, id=id)
os.remove(temppath)
bt = self[id]
bt.id = id # Make sure id is consistent
#LOG('Template Tool', 0, 'Indexing %r, isIndexable = %r' % (bt, bt.isIndexable))
bt.immediateReindexObject()
if REQUEST is not None:
REQUEST.RESPONSE.redirect("%s?portal_status_message=Business+Template+Downloaded+Successfully"
% self.absolute_url())
InitializeClass(TemplateTool) InitializeClass(TemplateTool)
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