Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Mikel

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Create ZIP files on the fly

// description of your code here

    def createZIP(self, startdate, enddate):
        """ Create the XTG file and the photos in a ZIP file """
        from StringIO import StringIO
        xtgString = StringIO()
        photofiles = []
        zorionagurrak = self.getZorionAgurrak(startdate, enddate)

        xtgString.write('<v6.50><e0>\r')
        for zorionagurra in zorionagurrak:
            a = self.createZorionAgurraXTG(zorionagurra).getvalue()
            xtgString.write(a)
            photofiles.append((zorionagurra['id'], zorionagurra['photo']))
            
        zipfile = self.appendFiles(xtgString, photofiles)

        request = self.request

        request.response.setHeader('Content-Type', 'application/zip')
        request.response.setHeader('Content-Disposition', 'attachment; filename=zorionagurrak.zip')
        request.response.write(zipfile.getvalue())
        return request.response

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS