示例#1
0
    def toZippedHtml(self, REQUEST, get_data=True):
        REQUEST.set('ZMS_INDEX_HTML', 1)
        REQUEST.set('ZMS_HTML_EXPORT', 1)

        #-- Create temporary folder.
        tempfolder = tempfile.mktemp()
        ressources = self.exportRessources(tempfolder,
                                           REQUEST,
                                           from_zms=self.getLevel() == 0,
                                           from_home=True)

        #-- Download HTML-pages.
        for lang in self.getLangIds():
            REQUEST.set('lang', lang)
            REQUEST.set('preview', None)
            self.recurse_downloadHtmlPages(self, tempfolder, lang, REQUEST)

        #-- Get zip-file.
        zipfiles = _fileutil.getOSPath('%s/*' % tempfolder)
        rtn = _fileutil.buildZipArchive(zipfiles, get_data)

        #-- Remove temporary folder.
        if not self.getConfProperty('ZMS.debug', 0):
            _fileutil.remove(tempfolder, deep=1)

        return rtn
示例#2
0
    def toZippedXml(self, REQUEST, get_data=True):

        #-- Create temporary folder.
        tempfolder = tempfile.mktemp()
        ressources = self.exportRessources(tempfolder, REQUEST)

        #-- Get xml-export.
        xml = self.toXml(REQUEST)

        #-- Write xml-export to file.
        xmlfilename = os.path.join(tempfolder, 'content.xml')
        _fileutil.exportObj(xml, xmlfilename)

        #-- Get zip-file.
        zipfiles = _fileutil.getOSPath('%s/*' % tempfolder)
        rtn = _fileutil.buildZipArchive(zipfiles, get_data)

        #-- Remove temporary folder.
        if not self.getConfProperty('ZMS.debug', 0):
            _fileutil.remove(tempfolder, deep=1)

        return rtn
示例#3
0
def exportFilter(self, id, REQUEST):
  # Set local variables.
  ob_filter = self.getFilterManager().getFilter(id)
  tempfolder, outfilename = self.initExportFilter( id, REQUEST)
  # Process filter.
  outfilename = processFilter(self, ob_filter, tempfolder, outfilename, REQUEST)
  # Return values.
  content_type = ob_filter.get('content_type', 'content/unknown')
  filename = 'exportFilter.%s'%content_type[content_type.find('/')+1:]
  # Zip File.
  if content_type == 'application/zip':
    data = _fileutil.buildZipArchive( outfilename, get_data=True)
  # Read File.
  else:
    standard.writeBlock( self, '[exportFilter]: Read %s'%outfilename)
    f = open(outfilename, 'rb')
    data = f.read()
    f.close()
  # Remove temporary folder.
  if not self.getConfProperty('ZMS.debug', 0):
    _fileutil.remove( tempfolder, deep=1)
  # Return.
  return filename, data, content_type
示例#4
0
 def buildZipArchive(self, files, get_data=True):
     warn(self, 'buildZipArchive', 'None')
     return _fileutil.buildZipArchive(files, get_data)