collective.catalogexport
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:
DTML Document,foo_doc DTML Document,bar_doc
Changelog
0.1 - 2008-11-14
Initial release
Metadata
Release files for collective.catalogexport 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| collective.catalogexport-0.1.tar.gz | 4.9 kB | Without provenance | Details |
Release files / collective.catalogexport-0.1.tar.gz
| Download URL | collective.catalogexport-0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
617bba0781f65098a5ba1d92a1fe8abe655717d377b6f3407be032d316e1cf40
|
|
BLAKE2b-256 checksum How to use checksums |
c63fca247a388eb86ed2f1e5f0c9a996f57002106a66854c52a42b605cc89d68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for collective.catalogexport 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.