This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
Persistent Cheetah templates


- Cheetah template engine,
- sources in filesystem,
- stored in ZODB,
- editable TTW, simple "$var" Cheetah syntax for non-technical user,
- able to testing in management web-form,
- able to reset from source.

Use cases:

- mail templates,
- editable HTML snippets and pages,
- other.

* Needed imports for these tests *

>>> import os, tempfile
>>> temp_dir = tempfile.mkdtemp()

>>> import zope.component
>>> import ice.template

>>> from zope.configuration import xmlconfig
>>> context = xmlconfig.file('meta.zcml', ice.template)

Create templates

1) Create source file using Cheetah syntax "$" for the variables::

>>> file = os.path.join(temp_dir, 'welcome.tmpl')

>>> open(file, 'w').write('''
... Dear $user_name!
... Welcome to $site_name!
... ''')

2) Register template::

>>> context = xmlconfig.string('''
... <configure
... xmlns=""
... xmlns:ice=""
... i18n_domain="test">
... <ice:template
... name="welcome"
... title="Welcome"
... storage="my-templates"
... source="%s"
... variables="user_name
... site_name"
... />
... </configure>
... ''' % file, context=context)

Create storage

Need create (one or more) local utility to store templates.
Note, the utility name used for lookup the storage::

>>> templates = ice.template.Templates()

>>> zope.component.provideUtility(
... templates, ice.template.ITemplates, 'my-templates')


Use template::

>>> data = {'user_name':u'Bob', 'site_name':''}

>>> templates.compileTemplate('welcome', data)
'\n Dear Bob!\n Welcome to!\n'

Manage templates

Looking all templates, registered for this storage::

>>> list(templates.getAllTemplates())
[(u'welcome', <ice.template.zcml.template object="" at="" ...="">)]

Get variables names::

>>> templates.getVariables('welcome')
[u'user_name', u'site_name']

Get template::

>>> templates.getTemplate('welcome')
'\n Dear $user_name!\n Welcome to $site_name!\n'

Edit template::

>>> templates.setTemplate('welcome', "$site_name for you, $user_name")

>>> templates.compileTemplate('welcome', data)
' for you, Bob'

Reset from source::

>>> templates.resetTemplate('welcome')
'\n Dear $user_name!\n Welcome to $site_name!\n'

>>> templates.compileTemplate('welcome', data)
'\n Dear Bob!\n Welcome to!\n'

Using property

Another way to use special property::

>>> class Pagelet(object):
... template = ice.template.PersistentTemplate('my-templates', 'welcome')
... def update(self):
... = {'user_name':'Man', 'site_name':''}
... def render(self):
... return self.template(

>>> view = Pagelet()
>>> view.update()
>>> view.render()
'\n Dear Man!\n Welcome to!\n'

Management UI

Management persistent Cheetah templates UI based on z3c.pagelet layers.

There are 3 views for management templates:

1) Listing of all storages.
2) Listing of all templates in a storage.
3) Edit form for given template, reload, testing, preview.

Actually, you need to do only one: register listing of all storages
pagelet using class ice.template.browser.storages.Pagelet (see example
in configure.zcml in ice.template.browser module), because (2) and (3)
are already registered. For examples, take a look configure.zcml
in ice.template.tests module.


Version 0.1.0 (2009-05-04)

- Initial release, this code is moved from common library.
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ice.template-0.1.0-py2.4.egg (33.3 kB) Copy SHA256 Checksum SHA256 2.4 Egg May 4, 2009
ice.template-0.1.0.tar.gz (12.8 kB) Copy SHA256 Checksum SHA256 Source May 4, 2009

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting