JSON import - UPCnet/genweb.migrations GitHub Wiki

JSON import view

<site_root>/import_json

This view imports the contents of <plone project root>/var/json/import.json

This view doesn't show anything special on the browser "yet". Note it is best to perform migrations using the zcdebug instance running in fg to be able to see the logs.

JSON format

The import.json file must be a list of objects, where each object needs to have defined at least:

  • _id: String. Normalized unique object id in the ZODB
  • _path: String. Normalized path in the plone site (usually contains id)
  • _type: String. Object type name
  • language: String. Short language code
  • excludeFromNav: Boolean. Whether to exclude the object from the site navigation or not.
  • creators: List. List of usernames of the creators of the object.

Other optional basic fields include:

  • _local_roles: Dictionnary. Defined local roles for the object with username/group as key and a list of roles as the value.
  • _translations: Dictionnary. Defined translations with short language code as key and the path of the translation objectas value.
  • _translationOf: String. Path of the object being translated.

In order to mantain creation and publication dates:

  • creation_date: ISO format datetime. Date of the creation of the object in the ZODB.
  • modification_date : ISO format datetime. Date of the last modification of the object (most likely, publication date).
  • _workflow_history : Complext object. Dictionnary of workflows. See the example

On top of this, the fields belonging to the type need to be filled in. For more details check the field names of the data in the portal_catalog for the type to import. Alternatively use the get_item view from jsonify package

  • title : String. Almost all objects have a title.

As an example, a News Item with workflow

[{
    "id": "test_news_item",
    "_path": "/news/test_news_item",
    "_type": "News Item",
    "language": "en",
    "excludeFromNav": false,
    "creators": [
        "admin"
    ],
    "_local_roles": {
        "admin": [
            "Owner"
        ],
        "test_user": [
            "Editor"
        ]
    },
    "creation_date": "2014/04/23 12:00:00",
    "modification_date": "2014/04/23 12:01:00",
    "_workflow_history": {
        "genweb_simple": [
            {
                "review_state": "visible",
                "actor": "admin",
                "time": "2014/04/23 12:00:00 GMT+2",
                "comments": "",
                "action": null
            },
            {
                "review_state": "published",
                "actor": "admin",
                "time": "2014/04/23 12:01:00 GMT+2",
                "action": "publish",
                "comments": ""
            }
        ]
    },
    "_translations": {
        "es": "/noticias/noticia-test-1",
        "ca": "/noticies/noticia-test",
        "en": "/news/test-news-item"
    },
    "_translationOf": "/noticies/noticia-test",
    "title": "Title of news item",
    "description": "Description of news item",
    "text": "Actual text of the news item, can be HTML but needs to be escaped"
}]

More details on import

⚠️ **GitHub.com Fallback** ⚠️