Subject field not being imported by Transmogrifier Schemaupdater

I am using transmogrifier to import data into a Plone 5.1.4 site. However, the subject field is not being imported. I have tried using csv and json source files.

My csv source:

_type,_folder,title,description,subject
Link,/path/to/folder,Some Title,"This is the description",http://www.somesite.com/link/url,"tag one,tag two"

My json source:

[
  {
    "_folder": "/path/to/folder",
    "_type": "Link",
    "subject": [
      "tag one",
      "tag two"
    ],
    "description": "This is the description",
    "remoteUrl": "http://www.somesite.com/url",
    "title": "Some Title"
 }

]

My config:

[transmogrifier]
include = mypackage.data.base
pipeline =
json_source
title_to_id
generate_path
disable_versioning
constructor
enable_versioning
schemaupdater
reindexobject
logger

[json_source]
blueprint = mypackage.data.jsonsource
directory = mypackage.data:source/json/

[csv_source]
blueprint = collective.transmogrifier.sections.csvsource
filename = mypackage.data:source/csv/file.csv

[fix_category]
blueprint = collective.transmogrifier.sections.inserter
key=string:subject
value=python:tuple(item['categories'].split(","))

As you see in the above config I also tried using an inserter blueprint to transform the subject into a tuple. I also tried list.

Is this a bug? Or am I missing something?

What is item['categories']?? It looks to me like you are overwriting the subject with that...

Otherwise the subject in your json source looks OK to me

I also note you aren't using blueprint = collective.jsonmigrator.jsonsource. Maybe there's an issue in your mypackage.data.jsonsource?

Thank you for your reply.

The pipeline where 'categories' is used is just a remnant of an experiment. The source key from the json file was named as such so I can process the value and assign the processed value to a new key, subject.

I am using a copied json source pipeline from ftw.inflator which allows a json file to contain several items to import. AFAIK, jsonsource from c.jsonmigrator expects 1 item for each json file. ftw.inflator adds a custom "Add Plone" button in the ZMI and I did not want it so I just copied the relevant code.

I tried using c.jsonmigrator but I get the same results. The values for subject is still being left out in the imported items.

The correct key to use is subjects (with an s) and not just subject in the data source. The ICategorization behavior uses subjects. However, the attribute persisted in the item is just subject.

1 Like