plonedexteritytransmogrifier

Setting the default page using quintagroup.transmogrifier generic setup import doesn't work with dexterity


We're using a quintagroup.transmogrifier content import profile to load content for our automated tests (very useful). Setting the default page doesn't seem to work.

The docs suggest quintagroup.transmogrifier supports setting default pages but not whether it does for generic set-up import steps. I eventually figured out you need to add a properties.xml file into the folder of the folderish item with the following:

<?xml version="1.0" encoding="utf-8"?>
<properties>
    <property name="default_page" type="string">
        index
    </property>
</properties>

where index is replaced by the id of the default page and also in your import.cfg you need

[transmogrifier]
pipeline =
    reader
    …
    propertiesimporter

[reader]
…
.properties.xml = propertymanager

[propertiesimporter]
blueprint = quintagroup.transmogrifier.propertiesimporter

However this doesn't work. We're running Plone 4.1rc3 + Dexterity 1.0 and presumably it's not compatible with Dexterity. I've tracked down the bit of code in quintagroup.transmogrifier.propertymanager.PropertiesImporterSection where it is falling down:

        path = item[pathkey]
        obj = self.context.unrestrictedTraverse(path, None)

Here path is a unicode string and unrestrictedTraverse returns None. If you use a byte string then it returns the correct object. Is this an incompatibility with Dexterity or am I doing something wrong?


Solution

  • This is a bug you'll need to report with the authors of the quintagroup.transmogrifier package. Paths must always be ASCII bytestrings, not Unicode objects. All sections in collective.transmogrifier (the underlying engine that quintagroup.transmogrifier uses) encode paths to ASCII.

    Here is a code snippet from collective.transmogrifier.sections.constructor for example:

         type_, path = item[typekey], item[pathkey]
    
         fti = self.ttool.getTypeInfo(type_)
         if fti is None:                           # not an existing type
             yield item; continue
    
         path = path.encode('ASCII')
         elems = path.strip('/').rsplit('/', 1)
         container, id = (len(elems) == 1 and ('', elems[0]) or elems)
         context = self.context.unrestrictedTraverse(container, None)
    

    Report it to the dedicated issue tracker on Plone.org so the authors can fix it for you.