This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Genshi integration in Grok

Project Description

Update 2013-05-27: I’m no longer using this project, if somebody wants to take over maintanance, email me.

megrok.genshi

megrok.genshi makes it possible to use Genshi templates in Grok. The project is no longer maintained due to lack of usage, but can still work as an example of how to do template integration in Grok.

For more information on Grok and Genshi see:

Requirements

  • Genshi. Tested with v 0.5.1.
  • Grok v0.14 or later. Tested with 0.14.

Installation

To use Genshi under Grok all you need is to install megrok.genshi as an egg and include it’s zcml. The best place to do this is to make megrok.genshi a dependency of your application by adding it to your install_requires list in setup.cfg. If you used grokprojet to create your application setup.cfg is located in the project root. It should look something like this:

install_requires=['setuptools',
                  'grok',
                  'megrok.genshi',
                  # Add extra requirements here
                  ],

Then include megrok.genshi in your configure.zcml. If you used grokproject to create your application it’s at src/<projectname>/configure.zcml. Add the include line after the include line for grok, but before the grokking of the current package. It should look something like this:

<include package="grok" />
<include package="megrok.genshi" />
<grok:grok package="." />

Then run bin/buildout again. You should now see buildout saying something like:

Getting distribution for 'megrok.genshi'.
Got megrok.genshi 1.0.

That’s all. You can now start using Genshi in your Grok application!

Usage

megrok.genshi supports the Grok standard of placing templates in a templates directory, for example app_templates, so you can use Genshi by simply placing the Genshi templates in the templates directory, just as you would with ZPT templates. Although Genshi itself doesn’t have a standard for the file extensions for Genshi templates, Grok needs to have an association between an extension and a type so it knows which type of template each template is. megrok.genshi defines the extension .g for Genshi HTML templates and .gt for Genshi Text templates. Genshi can also include templates, and although you can use any extension for this we recommend you use .gi for any include templates, to avoid any clashes with other templating languages.

You can also use Genshi templates inline. The syntax for this is:

from megrok.genshi.components import GenshiMarkupTemplate, GenshiTextTemplate
index = GenshiMarkupTemplate('<html>the html code</html>')
index = GenshiMarkupTemplate('Text templates')

Or if you use files:

from megrok.genshi.components import GenshiMarkupTemplate, GenshiTextTemplate
index = GenshiMarkupTemplate(filename='thefilename.html')
index = GenshiMarkupTemplate(filename='thefilename.txt')

Authors

CHANGES

Version 1.0

  • Support for Grok 0.14. (Paul Wilson)

Version 0.9

  • Initial release
Release History

Release History

This version
History Node

1.0

History Node

0.9

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
megrok.genshi-1.0.zip (15.6 kB) Copy SHA256 Checksum SHA256 Source Dec 9, 2008

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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