Can buildout create content as part of a Plone install?

倖福魔咒の 提交于 2019-12-01 07:32:34

In principle buildout can do anything you can code, as long as you create a recipe to do the thing for you.

Luckily, someone already created a recipe to create the plone site for you, called collective.recipe.plonesite:

[buildout]
parts = 
    ...
    plonesite

[plonesite]
recipe = collective.recipe.plonesite
site-id = <site>
profiles-initial =
    <site>.policy.profile-default
post-extras =
    ${buildout}/src/<site>.content/site/content/create_content.py

The recipe provides several hooks that let you control site creation, and execute system commands before or after the site is created or extra python code before or after GS profiles are run.

In the above example post-extras runs a create_content.py script with the variables app and site set:

from Products.CMFPlone.utils import _createObjectByType

if 'someobject' not in site:
    _createObjectByType('SomeType', site, 'someobject', title='Foo Bar')
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!