扩展可以在Plone安装中创建内容吗? [英] Can buildout create content as part of a Plone install?

查看:90
本文介绍了扩展可以在Plone安装中创建内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力实现对站点的Plone的可重复部署,并使用扩展功能,基本上遵循Martin Aspeli的书 Professional Plone 4 Development .我可以使用源产品<site>.policy<site>.theme设置系统,并自动激活主题,但是在运行扩展时,在创建标准对象之前,我仍然必须实例化Plone站点并激活策略产品.该网站.

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. I can set up the system with my source products <site>.policy and <site>.theme, and have activated the theme automatically, but when I run buildout, I still have to instantiate a Plone site and activate the policy product, before creating the standard objects for the site.

构建可以在安装过程中检查诸如Plone站点对象或特定文件夹之类的内容对象是否存在,如果使用正确的设置不存在,则可以创建它们吗?我可以在单独的<site>.content产品中执行此操作,还是应该在<site>.policy中处理?

Can buildout check for the existence of content objects like the Plone site object or particular folders during setup, and create them if they don't exist with the right settings? Can I do that in a separate <site>.content product, or should this be handled in the <site>.policy?

推荐答案

从原则上讲,只要您创建一个食谱来为您做这件事,构建就可以完成您可以编写的任何事情.

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

幸运的是,某人已经创建了一个配方来为您创建plone网站,名为 collective.recipe.plonesite :

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

该食谱提供了多个挂钩,可让您控制网站的创建,并在创建网站之前或之后执行系统命令,或者在运行GS配置文件之前或之后执行额外的python代码.

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.

在上面的示例中,post-extras运行带有变量appsitecreate_content.py脚本:

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')

这篇关于扩展可以在Plone安装中创建内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆