def create_zipfile(self, package): tmpfile = TemporaryFile() BindingDOMSupport.SetDefaultNamespace(u'http://bar.admin.ch/arelda/v4') with ZipFile(tmpfile, 'w', ZIP_DEFLATED, True) as zipfile: package.write_to_zipfile(zipfile) return tmpfile
def __call__(self): BindingDOMSupport.SetDefaultNamespace(u'http://bar.admin.ch/arelda/v4') package = SIPPackage(self.context) tmpfile = self.create_zipfile(package) size = tmpfile.tell() response = self.request.response response.setHeader( "Content-Disposition", 'inline; filename="%s.zip"' % package.get_folder_name()) response.setHeader("Content-type", "application/zip") response.setHeader("Content-Length", size) return TempfileStreamIterator(tmpfile, size)