enabled_dotted_names = schema.List(
title=u"Interface dotted-names on which zipexport is enabled.",
default=[u"Products.CMFCore.interfaces._content.IContentish"
, u"Products.CMFCore.interfaces._tools.IDirectoryView"],
value_type=schema.TextLine())
representations/filesystem.py
from ftw.zipexport.representations.general import NullZipRepresentation
from OFS.interfaces import IItem
from StringIO import StringIO
from Products.CMFPlone.utils import safe_unicode
from zope.component import adapts
from zope.interface import implements
from zope.interface import Interface
class FileZipRepresentation(NullZipRepresentation):
"""
filesystem zip export implementation
note, todo: returns img src link for image, not image itself
"""
implements(IZipRepresentation)
adapts(IItem, Interface)
def __init__(self, context, request):
self.context = context
self.request = request
def get_files(self, path_prefix=u"", recursive=True, toplevel=True):
filename = safe_unicode(self.context.getId() or self.context.id)
yield self.get_file_tuple(filename, path_prefix)
def get_file_tuple(self, filename, path_prefix):
path = u'{0}/{1}'.format(safe_unicode(path_prefix),
safe_unicode(filename))
stream_data = StringIO(self.context)
return (path, stream_data)
I have a use case where pdf files on the filesystem need to be zipped:
browser/configure.zcml
interfaces.py
representations/filesystem.py