Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install megrok.genshi

How to install megrok.genshi

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install megrok.genshi
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0 Available View build log
Windows (64-bit)
1.0 Available View build log
Mac OS X (10.5+)
1.0 Available View build log
Linux (32-bit)
1.0 Available View build log
Linux (64-bit)
1.0 Available View build log
 
License
ZPL
Dependencies
Lastest release
version 1.0 on Jan 5th, 2011

megrok.genshi

megrok.genshi makes it possible to use Genshi templates 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:

System Message: WARNING/2 (<string>, line 26)

Literal block expected; none found.

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:

System Message: WARNING/2 (<string>, line 43)

Literal block expected; none found.

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:

System Message: WARNING/2 (<string>, line 65)

Literal block expected; none found.

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

Or if you use files:

System Message: WARNING/2 (<string>, line 71)

Literal block expected; none found.

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

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.