Skip to main content

Create content structures from JSON configurations

Project description

Create content structures from JSON files or Python dictionaries.

This package is meant as a helper to quickly create content structures from JSON files or Python structures for the purpose of pre-filling a site in development. It’s the successor of the package collective.setuphandlertools.

Examples

Register a post_handler in a GenericSetup profile:

<genericsetup:registerProfile
    name="basic_content"
    title="create basic content structure"
    directory="profiles/basic_content"
    description="Creates the basic content structure"
    provides="Products.GenericSetup.interfaces.EXTENSION"
    post_handler=".setuphandlers.basic_content"
    />

In your setuphandler.py:

from zope.component.hooks import getSite

def basic_content(context):
    content_structure = load_json('data/basic_content.json', __file__)
    create_item_runner(
        getSite(),
        content_structure,
        default_lang='en',
        default_wf_action='publish'
    )

And in your data/basic_content.json:

[
    {
        "type": "Folder",
        "id": "main",
        "title": "Main Folder",
        "childs": [
            {"type": "Page",   "title": "Page within Folder", "opts": {"default_page": true}},
            {"type": "Folder", "title": "Folder within Folder", "data": {"description": "Not much more in here."}}
        ]
    }
]

License

The project is licensed under the GPLv2.

Changelog

1.0 (2018-12-01)

  • Initial release. [thet]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.contentcreator-1.0.tar.gz (11.7 kB view details)

Uploaded Source

File details

Details for the file collective.contentcreator-1.0.tar.gz.

File metadata

  • Download URL: collective.contentcreator-1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

File hashes

Hashes for collective.contentcreator-1.0.tar.gz
Algorithm Hash digest
SHA256 74ff587cf359ed7e89cf96dd6c2ba3eee4ec1bcfe70a6249fcedfb1b73c9b721
MD5 5fb70cfd5abf70e80dfba31f08527ad2
BLAKE2b-256 0a5179c36d1c2661136b34e55775606e6b63d9c74b92336596bc9af73d50aaf0

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page