Back to index

plone3  3.1.7
export.py
Go to the documentation of this file.
00001 from Products.CMFCore.utils import getToolByName
00002 
00003 def export(self):
00004     ct = getToolByName(self, 'portal_catalog')
00005     ut = getToolByName(self, 'portal_url')
00006     mt = getToolByName(self, 'marshaller_registry')
00007     paths = []
00008     for pt in ('News Item', 'Link', 'Document', 'Image', 'File'):
00009         for r in ct(portal_type=pt):
00010             paths.append(ut.getRelativeUrl(r.getObject()))
00011 
00012     response = self.REQUEST.RESPONSE
00013     response.setHeader('content-type', 'application/octet-stream')
00014     response.setHeader('content-disposition', 'attachment; filename=export.zip')
00015     data = mt.export(self, paths).read()
00016     response.setHeader('content-length', len(data))
00017     return response.write(data)