Importing and Exporting Arboreal trees
======================================

Arboreal uses BTrees for storage of the Arboreal tree structures. It seems that those are not exportable to a .zexp file
So, a simple xml-based import/export mechanisme has been built.

exporting
---------

The code is in a 'utils' module, so it can easily be used from an external method. The reason for this approach is
that it is not always possible to upgrade Arboreal to the newest version of the software. In that case the following approach will do:

- put the utils.py module in the older imcompatible Arboreal Product
- Write a small external method to export the trees as xml

If the software can be updated, the method 'exportToXML' can be called directly on the portal_arboreal tool (from the browser).
A file 'arboreal.xml' will be written in INSTANCE_HOME.

importing
---------

To import a tree:

- put a file 'arboreal.xml' in INSTANCE_HOME
- call 'importFromXML' directly on the 'portal_arboreal' tool (from the browser).

xml-structure
-------------

structure of the xml file should be:

<arboreal>
    <treemanager id="2007-etc." title="blaat">
        <arborealnode id="2007-etc2." title="hallo">
        </arborealnode>
    </treemanager>
</arboreal>

There can be more than one treemanager. Arborealnodes can be nested.

preserving ids
==============

The import method has a flag for preserving the id's of the treemanagers and arborealnodes.
The reason is that these id's are probably used in some content that also has to be imported. So,
in that case the id's need to be preserved, because these id's are used in the arboreal path's that are part of the content.

Dependencies
============

The in/export mechanism uses the elementtree library. So, that has to be available.
There is a nice windows installer, there are packages, and there is the standard distutils approach: 'python setup.py install', using
the same python that your Zope is using (see the elementtree website for details).

Caveats
=======

During development is seemed that elementtree (version 1.2.6) is not handling encoding correctly. What seems to work is:
- export as Latin encoded
- import and convert to utf-8
So, this is the approach in the code.

Todo
====

- Register the elementtree encoding problems
- Make a simple ZMI (or configlet) interface for import/export

