增强变色龙模板引擎与plone的集成
ftw.chameleon的Python项目详细描述
目录
Introduction
这个包增强了Chameleon与five.pt的plone的集成。
在我们的部署中,我们有源代码签出(git),我们可以在更新时提取它。 这可能会导致在运行实例中的下一个请求中更新模板, 这可能会导致错误,因为关联的代码尚未重新加载,因为 zope实例尚未重新启动。 为了使它更健壮,我们使用了Chameleon并启用了紧急加载 并禁用自动重新加载,以便在实例启动后它将不再 阅读模板。
当使用five.pt进行集成时,这些选项不能按预期工作 Chameleon与ViewPageTemplateFile实例结合使用。 ftw.chameleon包含使其正常工作的增强功能。
Enhancements
- zope.pagetemplate已修补,以便它考虑CHAMELEON_RELOAD 配置:当CHAMELEON_RELOAD被禁用时,它不会触发 即使模板已更改,也会重新记帐。
- 当启用CHAMELEON_EAGER时,所有模板都将在启动时生成。 这是通过在单独的线程中显式地烹饪所有已知模板来完成的。
- 变色龙编译模板时触发事件。
- 意外编译模板时记录警告或异常。 这有助于解决无法缓存的模板的点问题。
- 当启用CHAMELEON_EAGER时,portal_skins中的模板将 在plone网站的第一个请求后煮熟。
Compatibility
扑通一声4.3.x
Installation
production的构建示例:
[instance]eggs += ftw.chameleonenvironment-vars += CHAMELEON_EAGER true CHAMELEON_RELOAD false CHAMELEON_CACHE ${buildout:directory}/var/chameleon-cache FTW_CHAMELEON_RECOOK_WARNING true
开发的构建示例:
[instance]eggs += ftw.chameleonenvironment-vars += CHAMELEON_RELOAD true CHAMELEON_CACHE ${buildout:directory}/var/chameleon-cache
您需要确保缓存目录存在。这可以通过构建来完成:
[buildout]parts +=chameleon-cache[chameleon-cache]directory=${buildout:directory}/var/chameleon-cacherecipe=collective.recipe.shelloutputcommands= cmd1 = mkdir -p ${chameleon-cache:directory}[instance]environment-vars += CHAMELEON_CACHE ${chameleon-cache:directory}
Environment variables
Name | Description | Values | Recommendation |
^{tt6}$ | Parse and compile templates on startup. | ^{tt10}$, ^{tt11}$ | ^{tt10}$ |
^{tt4}$ | Reload templates when they have changed. | ^{tt10}$, ^{tt11}$ | ^{tt11}$ |
^{tt17}$ | File system cache. | Path to cache directory. | ^{tt18}$ |
^{tt19}$ | Warn when recooking templates. | ^{tt10}$, ^{tt11}$ | ^{tt10}$ |
^{tt23}$ | Exception when recooking templates. | ^{tt10}$, ^{tt11}$ | ^{tt10}$ when using Sentry. |
Development
- 转移此回购
- 克隆您的叉子
- 外壳:ln -s development.cfg buildout.cfg
- 外壳:python bootstrap.py
- 外壳:bin/buildout
运行bin/test测试您的更改。
或者通过运行bin/instance fg启动实例。
Changelog
1.2.0 (2017-12-04)
- 需要5.pt<;3.0。[mbaechtell]
- 将变更日志附加到包[Raphael-S]的详细说明中
1.1.2 (2017-06-26)
- 跳过precok_templates()中的持久模板以避免尝试 在关闭的zodb连接上操作。[lgraf]
1.1.1 (2016-11-21)
- 修复记录器名称(以前是ftw.ptcache)。[乔恩]
1.1.0 (2016-10-25)
- 预先确定z3c.jbot注册模板。[乔恩]
1.0.0 (2016-10-03)
- 初步实施。