Can buildout create content as part of a Plone install?

后端 未结 1 1501
北荒
北荒 2021-01-14 00:10

I\'m trying to achieve a repeatable deployment of Plone for a site, and using buildout, basically following Martin Aspeli\'s book Professional Plone 4 Development.

相关标签:
1条回答
  • 2021-01-14 00:38

    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')
    
    0 讨论(0)
提交回复
热议问题