Friday, February 25, 2011

How to import a nested folder structure containing files



Problem

I have a deeply nested folder structure containing file objects (.doc, .xls, .ppt etc.) and I want to import them into Plone


Approach

By declaring file objects to be IDAVAware, we could use GenericSetup to import them, an idea I got from here:

http://reinout.vanrees.org/weblog/2006/09/13/creating-content-with-genericsetup.html


Steps

1. Mark ATFile as IDAVAware by adding the following in your configure.zcml:


<five:implements
        class="Products.ATContentTypes.content.file.ATFile"
        interface="Products.GenericSetup.interfaces.IDAVAware"
   />

2. Create a structure folder under the default profile of your product and create the desired folder structure there.

3. Recursively create the .objects, .preserve and .properties files under the structure folder. To make this easy, you can use the prepare_content recipe from collective.migrator. Your buildout step should look something like this:



[prepare_content]
recipe = collective.migrator:prepare_content
top_folder = /plone/src/my.product/my/product/profiles/default/structure/My Folder Structure/


4. Reinstall your product using the portal_quickinstaller



1 comment:

  1. Would it not work to turn on ftp-server in zope.conf and connect/upload via FTP? Maybe the deep nesting is a problem. I've only used this for shallow uploading.

    ReplyDelete