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 repoze.bfg.mako

How to install repoze.bfg.mako

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install repoze.bfg.mako
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.3 Available View build log
0.2 Available View build log
0.1 Available View build log
Windows (64-bit)
0.3 Available View build log
0.2 Available View build log
0.1 Available View build log
Mac OS X (10.5+)
0.3 Available View build log
0.2 Available View build log
0.1 Available View build log
Linux (32-bit)
0.3 Available View build log
0.2 Available View build log
0.1 Available View build log
Linux (64-bit)
0.3 Available View build log
0.2 Available View build log
0.1 Available View build log
 
License
BSD-derived (http://www.repoze.org/LICENSE.txt)
Dependencies
Lastest release
version 0.3 on Jan 5th, 2011

These are bindings for the Mako templating system for the `repoze.bfg <http://bfg.repoze.org/`_ web framework.

High-Level API

The API follows the pattern of the "default" template API for repoze.bfg, which includes three functions: get_template, render_template, and render_template_to_response. From within a repoze.bfg view function, you might do:

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

Literal block expected; none found.

from webob import Response

from repoze.bfg.renderers import get_renderer template = get_renderer('templates/foo.mak') return Response(template.render_unicode(foo=1))

Or:

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

Literal block expected; none found.

from repoze.bfg.renderers import render s = render('templates/foo.mak', {foo:1}) return Response(s)

Or:

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

Literal block expected; none found.

from repoze.bfg.renderers import render_to_response return render_to_response('templates/foo.mak', {foo:1})

All of these examples are equivalent. The first argument passed in to each of them (representing the template location) should be a file path relative to the lookup loader root.

The value passed to render or render_to_response should be one of the following:

  • A dictionary representing the values passed to the template.

  • A tuple, consisting of two values in the form ``(function_name,

    System Message: WARNING/2 (<string>, line 42); backlink

    Inline literal start-string without end-string.

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

Bullet list ends without a blank line; unexpected unindent.

values)``. If a tuple is returned, the def named after function_name in the template is rendered instead of the entire template using the values provided, which must be a dictionary). Positional arguments to the function defined within the template are filled in by name using the same-named values within the values dictionary.

Configuring the Loookup Loader

In your bfg application's .ini file, use a mako.directories setting:

[app:main]

System Message: ERROR/3 (<string>, line 57)

Inconsistent literal block quoting.

use = egg:mypackage mako.directories = mypackage:templates anotherpackage:templates reload_templates = true debug_authorization = false debug_notfound = false

mako.directories should be a sequence of absolute directory names or resource specifications, one per line.

Other values:

mako.input_encoding Set the mako template input encoding. The default is utf-8.

reload_templates If this is True, Mako templates will be checked for changes at every rendering boundary. This slows down rendering but is convenient for development.

Ensuring the Mako Renderer Extension is Active

repoze.bfg.mako can also act as a "renderer" for a view when it is active in the repoze.bfg application you're developing:

@bfg_view(renderer='templates/foo.mak')

System Message: ERROR/3 (<string>, line 84)

Inconsistent literal block quoting.

def aview(request): return {'foo':1}

There are two ways to make sure that the mako extension is active. Both are completely equivalent.

#) Ensure that some ZCML file with an analogue of the following contents is executed:

<include package="repoze.bfg.mako"/>

#) Call the add_renderer method of a Configurator in your application:

from repoze.bfg.mako import renderer_factory config.add_renderer(.'mak', renderer_factory) config.add_renderer(.'mako', renderer_factory)

In either case, files with the .mak and .mako extensions are now considered to be Mako templates.

Note that when mako is used as a renderer in this fashion, the repoze.bfg context that is usually available as context within the template global namespace is available as _context (the context name without the underscore is reserved for internal Mako usage).

Installation

Install using setuptools, e.g. (within a virtualenv):

$ easy_install -i http://dist.repoze.org/bfg/dev/simple repoze.bfg.mako

Creating a Mako repoze.bfg Project

After you've got repoze.bfg.mako installed, you can invoke the following command to create a Mako-based repoze.bfg project:

$ paster create -t bin/paster create -t bfg_mako_starter

Reporting Bugs / Development Versions

Visit http://bugs.repoze.org to report bugs. Visit http://svn.repoze.org to download development or tagged versions.

0.3 (2010-09-19)

  • A repoze.bfg.mako renderer may now be called with a tuple,

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

Bullet list ends without a blank line; unexpected unindent.

consisting of two values in the form (function_name, values). If a tuple is provided to a renderer, the def named after function_name in the template is rendered instead of the entire template using the values provided, which must be a dictionary).

0.2 (2010-09-06)

  • Removed repoze.bfg.mako functions named render_template,

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

Bullet list ends without a blank line; unexpected unindent.

render_template_to_response, get_template and get_renderer. As of repoze.bfg 1.3a6, use of these functions should be replaced with usage of similarly-named functions present in the repoze.bfg.renderers module .

  • Added integration tests for imperative rendering and ZCML loading.

0.1 (2010-07-24)

  • Initial release.

Docutils System Messages

System Message: ERROR/3 (<string>, line 4); backlink

Unknown target name: "repoze.bfg <http://bfg.repoze.org/".

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.