Schema v1 reference (cookiecutter.json)#
Important
Cookieplone 2.0 does not support the v1 format, neither for templates nor for the root of a template repository. This page describes the format only to help you migrate to Schema v2 reference (cookieplone.json) and Repository configuration (cookieplone-config.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"
}
}
Migrate a template to v2#
To migrate a template's cookiecutter.json to cookieplone.json:
Rename
cookiecutter.jsontocookieplone.json.Add a top-level
idwith the template ID, and move__cookieplone_templatethere if the file has it.Move the fields under
schema.properties, and addschema.version: "2.0". Turn each field into an object withtype,title, anddefault.Move prompts from
__prompts__into each field'stitle, and choice labels intooneOfentries.Move validators from
__validators__into each field'svalidatorkey.Turn
__keycomputed fields into properties with"format": "computed", and_keyconstants into properties with"format": "constant".Move
_extensionstoconfig.extensions, and list every Cookieplone filter the template uses there.Move
_copy_without_rendertoconfig.no_render.Move
__cookieplone_subtemplatestoconfig.subtemplates, converting each[id, title, enabled]list to an object{"id": "...", "title": "...", "enabled": "..."}.Add version pins to
config.versionsas needed, and reference them in template files as{{ versions.<key> }}.
Migrate a repository's root cookiecutter.json#
Before 2.0, the root of a template repository could hold a cookiecutter.json with a templates key:
{
"templates": {
"project": {
"path": "./templates/project",
"title": "A Plone project",
"description": "Full Plone project with backend and frontend."
}
}
}
To migrate it to cookieplone-config.json:
Rename the file to
cookieplone-config.json.Add
"version": "1.0"and atitlefor the repository.Add
groups, and assign every template to exactly one group.
See Template repositories for the structure of the result.
Related pages#
Schema v2 reference (cookieplone.json): the v2
cookieplone.jsonformat.Repository configuration (cookieplone-config.json): the
cookieplone-config.jsonformat.Validators reference: built-in validators and automatic validators by field name.