Enhance Chameleon templating engine integration into Plone
Project description
Introduction
This package enhances the integration of Chameleon in Plone with five.pt.
In our deployments we have source checkouts (git) which are pulled on updates. This may cause templates to be updated on the next request in running instances, which may cause errors because the associated code was not yet reloaded because the zope instance was not yet rebooted. In order to make that more robust we use Chameleon with eager-loading enabled and auto-reload disabled, so that after an instance is started it will no longer read templates.
These options do not work as expected when using five.pt to integrate Chameleon in combination with ViewPageTemplateFile instances. ftw.chameleon contains enhancements for making that work well.
Enhancements
zope.pagetemplate is patched on Plone 4 so that it considers the CHAMELEON_RELOAD configuration: when CHAMELEON_RELOAD is disabled it does not trigger a recooking of the template even when it has changed. CHAMELEON_RELOAD is not available in Plone 5 as it already patches zope.pagetemplate to not recook templates unless Plone is run in debug mode.
When CHAMELEON_EAGER is enabled, all templates will be cooked on startup. This is done by explicitly cooking all known templates in a separate thread.
Fire an event when chameleon compiles templates.
Log warnings or raise exceptions when templates are compiled unexpectedly. This helps to pin-point problems with templates which are not cacheable.
When CHAMELEON_EAGER is enabled, the templates in portal_skins will be cooked after the first request on the Plone site.
Compatibility
Plone 4.3.x and Plone 5.1.x.
Installation
Buildout example for production:
[instance]
eggs +=
ftw.chameleon
environment-vars +=
CHAMELEON_EAGER true
CHAMELEON_RELOAD false
CHAMELEON_CACHE ${buildout:directory}/var/chameleon-cache
FTW_CHAMELEON_RECOOK_WARNING true
Buildout example for development:
[instance]
eggs +=
ftw.chameleon
environment-vars +=
CHAMELEON_RELOAD true
CHAMELEON_CACHE ${buildout:directory}/var/chameleon-cache
You need to make sure that the cache-directory exists. This can be done with buildout:
[buildout]
parts += chameleon-cache
[chameleon-cache]
directory = ${buildout:directory}/var/chameleon-cache
recipe = collective.recipe.shelloutput
commands =
cmd1 = mkdir -p ${chameleon-cache:directory}
[instance]
environment-vars +=
CHAMELEON_CACHE ${chameleon-cache:directory}
Environment variables
Name |
Description |
Values |
Recommendation |
CHAMELEON_EAGER |
Parse and compile templates on startup. |
true, false |
true |
CHAMELEON_RELOAD (Plone4 only) |
Reload templates when they have changed. |
true, false |
false |
CHAMELEON_CACHE |
File system cache. |
Path to cache directory. |
.../var/chameleon-cache |
FTW_CHAMELEON_RECOOK_WARNING |
Warn when recooking templates. |
true, false |
true |
FTW_CHAMELEON_RECOOK_EXCEPTION |
Raise exception when recooking templates. |
true, false |
true when using Sentry. |
See also the Chameleon documentation.
Development
Fork this repo
Clone your fork
Shell: ln -s development.cfg buildout.cfg
Shell: python bootstrap.py
Shell: bin/buildout
Run bin/test to test your changes.
Or start an instance by running bin/instance fg.
Links
Copyright
This package is copyright by 4teamwork.
ftw.chameleon is licensed under GNU General Public License, version 2.
Changelog
1.3.0 (2019-10-01)
Add support for Plone 5.1. [mbaechtold]
Fix tests for Plone 5.1 [djowett-ftw]
Remove CHAMELEON_RELOAD option in Plone 5 as it does not recook templates when running in production mode (which is our only concern). [djowett-ftw]
1.2.0 (2017-12-04)
Require five.pt < 3.0. [mbaechtold]
Append changelog to long description of package [raphael-s]
1.1.2 (2017-06-26)
Skip persistent templates in precook_templates() to avoid attempting to operate on a closed ZODB connection. [lgraf]
1.1.1 (2016-11-21)
Fix logger name (was ftw.ptcache). [jone]
1.1.0 (2016-10-25)
Precook z3c.jbot registered templates. [jone]
1.0.0 (2016-10-03)
Initial implementation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ftw.chameleon-1.3.0.tar.gz
.
File metadata
- Download URL: ftw.chameleon-1.3.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d4e08233913356fd4cecc75b94f6d1e0ee5b9c4186e704fafd39b93816c48ad |
|
MD5 | 5a43e3f1bc9e8837354a88dbc231460b |
|
BLAKE2b-256 | 82ec82f4c3da34c9c99e265e7440cb5163bea8b4a52b030ebafa11cada6883e0 |