Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install collective.catalogexport

How to install collective.catalogexport

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install collective.catalogexport
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1 Available View build log
Windows (64-bit)
0.1 Available View build log
Mac OS X (10.5+)
0.1 Available View build log
Linux (32-bit)
0.1 Available View build log
Linux (64-bit)
0.1 Available View build log
 
License
GPL
Dependencies
Lastest release
version 0.1 on Jan 5th, 2011

The data contained in tabular form in ZCatalogs is often exactly the data site admins frequently want to export into some other format, such as CSV. This package provides views for exporting the catalog data into various formats.

Currently, only exporting the whole catalog with all metadata/brains/columns as CSV is supported. I plan to add support for submiting arbitrary index queries and for controlling the metadata/brains/columns exported.

Start with a catalog with some indexes and metadata/brains/columns and a few objects indexed.

>>> self.folder.manage_addProduct['ZCatalog'].manage_addZCatalog(
...     'catalog', 'Catalog')
>>> catalog = self.folder.catalog
>>> catalog.addIndex('id', 'FieldIndex')
>>> catalog.addIndex('title', 'FieldIndex')
>>> catalog.indexes()
['id', 'title']
>>> catalog.addColumn('meta_type')
>>> catalog.addColumn('id')
>>> self.folder.manage_addProduct['OFSP'].manage_addDTMLDocument(
...     'foo_doc', 'Foo Document')
''
>>> catalog.catalog_object(self.folder.foo_doc)
>>> self.folder.manage_addProduct['OFSP'].manage_addDTMLDocument(
...     'bar_doc', 'Bar Document')
''
>>> catalog.catalog_object(self.folder.bar_doc)
>>> [(brain.meta_type, brain.id) for brain in catalog()]
[('DTML Document', 'foo_doc'), ('DTML Document', 'bar_doc')]

Open the export view in the browser specifying the export format as CSV.

>>> from Products.Five.testbrowser import Browser
>>> from Testing import ZopeTestCase
>>> self.setRoles(['Manager'])
>>> browser = Browser()
>>> browser.addHeader(
...     'Authorization', 'Basic %s:%s' %
...     (ZopeTestCase.user_name, ZopeTestCase.user_password))
>>> browser.handleErrors = False
>>> browser.open(catalog.absolute_url()+
...              '/export?Content-Type=text/csv')
>>> browser.isHtml
False
>>> print browser.headers
Status: 200 OK...
Content-Disposition: attachment...
Content-Type: text/csv...
>>> print browser.contents

XXX the testbrowser doesn't handle use of response.write(). I've verified that this works in a real browser:

System Message: WARNING/2 (<string>, line 68)

Literal block expected; none found.

DTML Document,foo_doc DTML Document,bar_doc

Changelog

0.1 - 2008-11-14
  • Initial release

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.