Data structure for images and files to feed transmogrify.dexterity

I'm having a very bad time trying to import a site from WordPress to Plone.

In the past we've been able to do so using transmogrify.wordpress but the Image and File content types were Archetypes-based.

I'm using the same configuration again but all my images and files are broken:

2018-06-28T11:36:03 ERROR Zope.SiteErrorLog 1530196563.930.869617206729 http://localhost:8080/Plone/wp-content/uploads/2018/06/foo.jpg/image_view
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 583, in do_setLocal_tal
  Module zope.tales.tales, line 696, in evaluate
   - URL: /home/hvelarde/.buildout/eggs/
   - Line 11, Column 0
   - Expression: <PathExpr standard:u'context/image/getSize'>
   - Names:
      {'args': (),
       'container': <Image at /Plone/wp-content/uploads/2018/06/foo.jpg>,
       'context': <Image at /Plone/wp-content/uploads/2018/06/foo.jpg>,
       'default': <object object at 0x7f235fb73b50>,
       'here': <Image at /Plone/wp-content/uploads/2018/06/foo.jpg>,
       'loop': {},
       'nothing': None,
       'options': {},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x7f233eca7a48>,
       'request': <HTTPRequest, URL=http://localhost:8080/Plone/wp-content/uploads/2018/06/foo.jpg/image_view>,
       'root': <Application at >,
       'template': <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x7f23153c96d0>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>,
       'view': <Products.Five.metaclass.SimpleViewClass from /home/hvelarde/.buildout/eggs/ object at 0x7f23153c9bd0>,
       'views': <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7f23153f2bd0>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 147, in _eval
  Module zope.tales.expressions, line 124, in _eval
  Module Products.PageTemplates.Expressions, line 97, in trustedBoboAwareZopeTraverse
  Module zope.traversing.adapters, line 136, in traversePathElement
   - __traceback_info__: (None, 'getSize')
  Module zope.traversing.adapters, line 50, in traverse
   - __traceback_info__: (None, 'getSize', [])
LocationError: (None, 'getSize')

I tried modifying the structure to something similar to what collective.jsonify exports, but images are also broken:

2018-06-28T12:04:36 ERROR root could not scale "<plone.namedfile.file.NamedBlobImage object at 0x7f233dbc3d70>" of
Traceback (most recent call last):
  File "/home/hvelarde/.buildout/eggs/plone.namedfile-3.0.9-py2.7.egg/plone/namedfile/", line 290, in cr
  File "/home/hvelarde/.buildout/eggs/plone.scale-1.4.1-py2.7.egg/plone/scale/", line 31, in scaleImage
    image =
  File "/home/hvelarde/.buildout/eggs/Pillow-3.3.0-py2.7-linux-x86_64.egg/PIL/", line 2317, in open
    % (filename if filename else fp))
IOError: cannot identify image file <open file '/home/hvelarde/my/project/var/blobstorage/0x00/0x00/0x0
0/0x00/0x00/0x03/0x7f/0x6f/0x03c886438d10ef33.blob', mode 'rb' at 0x7f233fcd7838>

transmogrify.dexterity has no documentation on this.

any hints?

For each image or file item, you need to build an special object in transmogrifier to let transmogrify.dexterity to create proper Image and File objects.

You need to build something like this:

item['_datafield_image'] = {
    'encoding': 'base64',
    'filename': filename,
    'data': content,
    'content_type': content_type,
    'size': size,


  • image (the dict key), is the name of the field you want to populate
  • content: is the actual content of the file or image encoded in base64
  • content_type: is the content type string (such as image/png)
  • filename: is the filename
1 Like

thanks! seems the problem was the encoding thing: my data was in fact not base64-encoded and I added the 'encoding': 'base64' by mistake.

besides that, and just to documented it here, the _datafield key needs to be _datafield_file for files and _datafield_image for images.

1 Like