This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

Introduction

Note

This is not a Plone add-on.

This library is an utility that helps developers to integrate vocabulary done using ATVocabularyManager to be imported using Generic Setup Python handlers and CSV sources.

It also support LinguaPlone (if present).

How to use

Just import the createVocabulary function and use it:

>>> portal_vocabularies = getToolByName(portal, 'portal_vocabularies')
>>> from collective.csv2atvocabularymanager.csv_import import createVocabulary
>>> createVocabulary(portal_vocabularies, fs_path, 'my.vocabulary.id',
...                  "My vocabulary", description='A vocabulary for...')

Where:

portal_vocabularies
is the ATVocabularyManager tool created after installing it
fs_path

is a filesystem path of a folder, where you must put you CSV sources.

If the code is called from a setuphandlers.py script, you can call something like:

>>> os.path.join(os.path.dirname( __file__ ), 'vocabularies')

This way the code will look for a “vocabularies” folder inside you project

vid
is the vocabulary id that will be created and a file with that name and “.csv” extension will be searched inside the fs_path folder.
title
is the title of the vocabulary
description
is the description of the vocabulary

Also, you have other optional additional parameters:

type_name
If the portal_type name of the vocabulary created (default is “SimpleVocabulary”)
sortMethod
is the sort method of the vocabulary
null_values
is a list of possible values that must be used as “null” (can be useful is your CSV is taken from a raw export from SQL database, and strings like “NULL” can be found inside the source).
change_master_with_language_id
is a boolean flag used to change the generated vocabulary term id, adding to it the language code suffix.

CSV format examples

A CSV file named “foo.bar.vocabulary.csv” in that format:

"id","en"
"item-1","Item one"
"item-2","Item two"
...

Will create a vocabulary entry with id “foo.bar.vocabulary”, with vocabulary terms ids “item-1” and “item-2”, … and titles “Item one”, “Item two”, …

The header row is required. While the id column’s name is not used, that language column name is used to specify the vocabulary term language code (so: normally use the portal default language).

You can also import item in different languages:

"id","en","it"
"item-1","Item one","Elemento 1"
"item-2","Item two","Elemento 2"
...

In that way you will create same terms as in previous example, and additional vocabulary terms with ids “item-1-it”, “item-2-it”, … and titles “Elemento 1”, “Elemento 2”, …

You can provide additional languages addim more columns. Just remember to keep the fist language column as the one with portal default language.

The real power of language columns will be used if you also install LinguaPlone. In that way you will create translations of vocabulary terms.

Final notes

Please, keep in mind that ATVocabularyManager already support Generic Setup integration for creating vocabularies at install time.

However you are foced to use the “IMS VDEX Vocabulary File”.

Please note also that vocabulary implementation from ATVM already provides a importCSV method.

Authors

This product was developed by RedTurtle Technology team.

Changelog

0.1.1 (2012-11-13)

  • Fixed packaging error (missing MANIFEST.in file) [keul]

0.1.0 (2012-11-12)

  • Initial release
Release History

Release History

0.1.1

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

0.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

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
collective.csv2atvocabularymanager-0.1.1.zip (26.1 kB) Copy SHA256 Checksum SHA256 Source Nov 13, 2012

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