Schema v1 reference (cookiecutter.json)#
Cookieplone supports the standard cookiecutter.json format (v1) for backwards compatibility.
New templates should use the v2 format (cookieplone.json) described in Schema v2 reference (cookieplone.json).
Basic structure#
A v1 schema is a flat JSON object. Keys are field names; values are the defaults.
{
"project_title": "My Plone Site",
"author_name": "Plone Community",
"port": 8080,
"database_backend": ["postgresql", "sqlite"]
}
A string value produces a free-text prompt.
An integer value produces a numeric prompt.
A list value produces a choice prompt; the first element is the default.
Hidden fields#
Keys that begin with a single underscore (_) are constant values.
They are not shown to the user.
{
"_schema_version": "1.0"
}
Computed fields#
Keys that begin with a double underscore (__) are computed from a Jinja2 expression.
They are not shown to the user.
{
"project_slug": "my-plone-site",
"__package_name": "{{ cookiecutter.project_slug | replace('-', '_') }}"
}
Custom prompts (__prompts__)#
The reserved key __prompts__ maps field names to human-readable question strings.
For choice fields, it also provides option labels.
{
"database_backend": ["postgresql", "sqlite"],
"__prompts__": {
"project_title": "What is the project title?",
"database_backend": {
"__prompt__": "Choose a database backend",
"postgresql": "PostgreSQL (recommended)",
"sqlite": "SQLite (development only)"
}
}
}
Custom validators (__validators__)#
The reserved key __validators__ maps field names to dotted import paths of validator functions.
{
"hostname": "example.com",
"__validators__": {
"hostname": "cookieplone.validators.hostname"
}
}
Validators declared in DEFAULT_VALIDATORS are applied automatically by field name and do not need to appear in __validators__.
See Validators reference.
Root cookiecutter.json for template repositories#
The root of a template repository uses a special cookiecutter.json format with a templates key.
This is different from the per-template schema described above.
{
"templates": {
"project": {
"path": "./templates/project",
"title": "A Plone project",
"description": "Full Plone project with backend and frontend."
}
}
}
See Template repositories for the full structure.
Upgrade path#
To upgrade a v1 schema to v2:
Rename
cookiecutter.jsontocookieplone.json.Replace the flat structure with the
"version": "2.0"and"properties"structure.Move prompts from
__prompts__into each field's"title"key.Move validators from
__validators__into each field's"validator"key.Convert computed fields from
__keyto a property with"format": "computed".
Related pages#
Schema v2 reference (cookieplone.json): the v2
cookieplone.jsonformat.Validators reference: built-in validators and autowiring by field name.
Template repositories: root
cookiecutter.jsonstructure.