This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Overview

ftw.zipexport provides a generic solution to export data from plone in a zip archive.

A user can export data with the “Export as Zip” action in document listings.

Install

Compatibility

For zipping files with a total size of over 4Gb python 2.7.4 is required.

Step-by-Step

  • Add ftw.zipexport to your buildout configuration
[instance]
eggs =
    ftw.zipexport
  • Run buildout
  • Install ftw.zipexport in portal_setup

Implementation

In a first step we have to collect all data to zip. Use the IZipRepresentation interface for this task.

The get_files function returns a list of tuples. The tuples consist of two values. First a relative path under which the file should show up in the zip. Second the data as eather a file or a stream.

class IZipRepresentation(Interface):

    def get_files(path_prefix='', recursive=True, toplevel=True):

By default we support basic data-types like folder and files. More complex data-types require an own adapter for IZipRepresentation.

Feel free to extend one of the predefined adapters: Predefined representations

The data generated by our IZipRepresentation then gets delivered to the ZipGeneration helper class.

class ZipGenerator(object):
        def add_file(file_path, file_pointer):
                Zipps the file and adds it to the archive.
                If large or many files are selected this function might take some time to execute.

        def generate():
                returns a temp file holding the generated zip

Here is the sample code of the described steps:

from zope.component import getMultiAdapter
from ftw.zipexport.generation import ZipGenerator
from ftw.zipexport.interfaces import IZipRepresentation

ziprepresentation = getMultiAdapter((self.folder, self.request), interface=IZipRepresentation)
with ZipGenerator() as zipgenerator:
        for file_path, file_pointer in ziprepresentation.get_files():
                zipgenerator.add_file(file_path, file_pointer)
        generated_zip_pointer = zipgenerator.generate()

The download is handled in a standard BrowserView which plainly reads from the temp file. For details check out the code: zipexportview.py.

Current supported data-types

  • IFolderish
  • IFileContent
  • IDexterityItem with IPrimaryFieldInfo

Path Normalization

Paths are automatically using Plone’s IFileNameNormalizer. If you want to use a custom normalization, you can pass it to the ZipGenerator:

from ftw.zipexport.generation import ZipGenerator
from Products.CMFPlone.utils import safe_unicode
import re

def normalize_path(path):
    path = safe_unicode(path).replace(u'\\', u'/')
    return re.sub(ur'[^\w\-.\/]', u'', path)

with ZipGenerator(path_normalizer=normalize_path) as zipgenerator:
    ...

Pass None to disable normalization completely:

from ftw.zipexport.generation import ZipGenerator

with ZipGenerator(path_normalizer=None) as zipgenerator:
    ...

Nice to have

  • Multithreading

Changelog

1.5.0 (2016-12-15)

  • Drop official support for Python 2.6 [jone]

1.4.0 (2016-12-12)

  • Add events for the ZIP exports [Rotonen]

1.3.1 (2016-02-09)

  • Do not fail when exporting AT folders with titles containing umlauts [fRiSi]
  • Fall back to object.id in case filename is not set. [fRiSi]

1.3.0 (2015-05-05)

  • Normalize all paths added to the ZIP file. [jone]
  • Handle path encoding in ZIP. [jone]
  • Added check if fs has enough space to create the zip file. [lknoepfel]

1.2.2 (2015-03-25)

  • Fixed a bug in the file export which occurred if the file to be exported did not have a blob but an OFS file. [mbaechtold]

1.2.1 (2014-06-05)

  • Fixed metadata version in default profile. [lknoepfel]

1.2.0 (2014-05-26)

  • Added option to select multiple interfaces on which the export is available. [lknoepfel]
  • Added error message when the content is too big to zip. This happens when the ZIP64 isn’t available and the content is bigger than 4GB. [lknoepfel]
  • Corrected error message when no zip-exportable content is selected. [lknoepfel]
  • Deny zipexport on unallowed content. [lknoepfel]
  • Include default AT image files. [jone]
  • Added French translation by I. Anthenien. [lknoepfel]

1.1.1 (2013-11-21)

  • Added handling for files with same filename. [lknoepfel]
  • Added a separate profile to install an additional zip-export document action. [deif]

1.1.0 (2013-10-14)

  • Added export limitation. [lknoepfel]
  • Fix encoding problem with nested folders containing umlauts in the title. [jone]

1.0.0 (2013-09-13)

  • Initial Development
Release History

Release History

1.5.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ftw.zipexport-1.5.0.tar.gz (25.2 kB) Copy SHA256 Checksum SHA256 Source Dec 15, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting