This is detailed sample instruction to Transmogrifier in Action on Plone 4.3.2.
$ cd src $ ../bin/zopeskel plone crgis.transmogrifier plone: A project for Plone add-ons This creates a Plone project (to create a Plone *site*, you probably want to use the one of the templates for a buildout). To create a Plone project with a name like 'plone.app.myproject' (2 dots, a 'nested namespace'), use the 'plone_app' template. If at any point, you need additional help for a question, you can enter '?' and press RETURN. Expert Mode? (What question mode would you like? (easy/expert/all)?) ['easy']: Version (Version number for project) ['1.0']: 0.1 Description (One-line description of the project) ['']: CRGIS Transmogrifier Package Register Profile (Should this package register a GS Profile) [False]: True Creating directory ./crgis.transmogrifier Replace 0 bytes with 119 bytes (0/0 lines changed; 5 lines added) Replace 918 bytes with 1074 bytes (0/32 lines changed; 6 lines added) ------------------------------------------------------------------------------ The project you just created has local commands. These can be used from within the product. usage: paster COMMAND Commands: addcontent Adds plone content types to your project For more information: paster help COMMAND ------------------------------------------------------------------------------
Update configure.zcml as follows:
<configure xmlns="http://namespaces.zope.org/zope" xmlns:five="http://namespaces.zope.org/five" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:genericsetup="http://namespaces.zope.org/genericsetup" xmlns:transmogrifier="http://namespaces.plone.org/transmogrifier" i18n_domain="crgis.transmogrifier"> <five:registerPackage package="." initialize=".initialize" /> <genericsetup:registerProfile name="default" title="crgis.transmogrifier" directory="profiles/default" description="CRGIS Transmogrifier Package Extension Profile" provides="Products.GenericSetup.interfaces.EXTENSION" /> <include package="collective.transmogrifier" /> <include package="collective.transmogrifier" file="meta.zcml" /> <transmogrifier:registerConfig name="crgis.importer.temple" title="CRGIS Importer for Temple Type" description="Transmogrifier Pipeline Config to Import Contents." configuration="import-temple.cfg" />
Update import-temple.cfg then:
[transmogrifier] pipeline = csvsource sqlsource type-inserter path-inserter folders constructor schema-updater state-inserter workflow-updater reindex-object [csvsource] blueprint = collective.transmogrifier.sections.csvsource filename = crgis.transmogrifier:temple-data.csv [sqlsource] blueprint = transmogrify.sqlalchemy dsn = postgresql://USERNAME:PASSWORD@localhost:5432/DB_NAME query = SELECT id, title, description FROM TB_NAME [type-inserter] blueprint = collective.transmogrifier.sections.inserter key = string:_type value = string:Temple [path-inserter] blueprint = collective.transmogrifier.sections.inserter key = string:_path value = string:/myfolder/${item/id} [folders] blueprint = collective.transmogrifier.sections.folders [constructor] blueprint = collective.transmogrifier.sections.constructor [schema-updater] blueprint = plone.app.transmogrifier.atschemaupdater [state-inserter] blueprint = collective.transmogrifier.sections.inserter key = string:_transitions value = string:publish [workflow-updater] blueprint = plone.app.transmogrifier.workflowupdater [reindex-object] blueprint = plone.app.transmogrifier.reindexobject
Note that csvsource section is for CSV source, and sqlsource section is for SQL source.
Add a file crgis/transmogrifier/profiles/default/transmogrifier.txt with these:
# this file contains transmogrifier profile names to run # on GenericSetup transmogrifier's step crgis.importer.temple
Update setup.py to include SQLAlchemy and psycopg2 dependency.
Finally, edit buildout.cfg:
eggs = plone.app.transmogrifier collective.transmogrifier transmogrify.sqlalchemy crgis.transmogrifier zcml = plone.app.transmogrifier collective.transmogrifier transmogrify.sqlalchemy
No comments:
Post a Comment