从JSON配置创建内容结构
项目描述
=========================
collective.contentcreator
=========================
从JSON文件或Python字典创建内容结构。
此包旨在作为快速从JSON文件或Python结构创建内容结构以用于预先填充开发站点的辅助工具。
它是包 `collective.setuphandlertools <https://github.com/collective/collective.setuphandlertools>`_ 的后续产品。
示例
--------
在GenericSetup配置文件中注册 ``post_handler``
.. code-block:: xml
<genericsetup:registerProfile
name="basic_content"
title="创建基本内容结构"
directory="profiles/basic_content"
description="创建基本内容结构"
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.basic_content"
/>
在你的 ``setuphandler.py``
.. code-block:: python
# -*- coding: utf-8 -*-
from collective.contentcreator import create_item_runner
from collective.contentcreator import load_json
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'
)
并在你的 ``data/basic_content.json``
.. 代码块:json
[
{
"@type": "Folder",
"id": "main",
"title": "主文件夹",
"items": [
{"@type": "Page", "title": "文件夹内的页面"},
{"@type": "Folder", "title": "文件夹内的文件夹", "description": "这里没有更多内容。"}
collective.contentcreator
=========================
从JSON文件或Python字典创建内容结构。
此包旨在作为快速从JSON文件或Python结构创建内容结构以用于预先填充开发站点的辅助工具。
它是包 `collective.setuphandlertools <https://github.com/collective/collective.setuphandlertools>`_ 的后续产品。
示例
--------
在GenericSetup配置文件中注册 ``post_handler``
.. code-block:: xml
<genericsetup:registerProfile
name="basic_content"
title="创建基本内容结构"
directory="profiles/basic_content"
description="创建基本内容结构"
provides="Products.GenericSetup.interfaces.EXTENSION"
post_handler=".setuphandlers.basic_content"
/>
在你的 ``setuphandler.py``
.. code-block:: python
# -*- coding: utf-8 -*-
from collective.contentcreator import create_item_runner
from collective.contentcreator import load_json
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'
)
并在你的 ``data/basic_content.json``
.. 代码块:json
[
{
"@type": "Folder",
"id": "main",
"title": "主文件夹",
"items": [
{"@type": "Page", "title": "文件夹内的页面"},
{"@type": "Folder", "title": "文件夹内的文件夹", "description": "这里没有更多内容。"}
]
}
]
许可协议
-------
本项目采用GPLv2许可。
变更日志
=========
2.0 (2018-12-03)
----------------
- 使用 `plone.restapi` 和基于 `plone.restapi.services.content.add` 的基本内容创建者。
这为我们提供了正确的值反序列化和模式验证。
例如,文本字段被正确反序列化为 `plone.app.textfield` 的值。
重大变更:JSON结构基于 `plone.restapi` 的JSON结构。
待定
查看:https://plonerestapi.readthedocs.io/en/latest/content.html#creating-a-resource-with-post
[thet]
1.0 (2018-12-01)
----------------
- 首次发布。
[thet]
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
collective.contentcreator-2.0.tar.gz (11.6 kB 查看哈希值)
关闭
collective.contentcreator-2.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ef8361ad326116767e00728cf1631052ebf8994d14dfb592f77cf32d13c4491f |
|
MD5 | bc57ccb7c79132a60aff29e679ff2052 |
|
BLAKE2b-256 | 5b8b223bab25f8be860e8dd534cc7346e3059ed7289e82f3ef8131c3d356a6db |