Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pyramid.pdf
Скачиваний:
10
Добавлен:
24.03.2015
Размер:
3.82 Mб
Скачать

11. TEMPLATES

RuntimeError: Caught exception rendering template.

-Expression: ‘‘wrong‘‘

-Filename: /home/fred/env/proj/proj/templates/mytemplate.pt

-Arguments: renderer_name: proj:templates/mytemplate.pt

template: <PageTemplateFile - at 0x1d2ecf0> xincludes: <XIncludes - at 0x1d3a130> request: <Request - at 0x1d2ecd0>

project: proj

macros: <Macros - at 0x1d3aed0> context: <MyResource None at 0x1d39130> view: <function my_view at 0x1d23570>

NameError: wrong

The output tells you which template the error occurred in, as well as displaying the arguments passed to the template itself.

11.8 Chameleon Template Internationalization

See Chameleon Template Support for Translation Strings for information about supporting internationalized units of text within Chameleon templates.

11.9 Templating With Mako Templates

Mako is a templating system written by Mike Bayer. Pyramid has built-in bindings for the Mako templating system. The language definition documentation for Mako templates is available from the Mako website.

To use a Mako template, given a Mako template file named foo.mak in the templates subdirectory in your application package named mypackage, you can configure the template as a renderer like so:

1

2

3

4

5

from pyramid.view import view_config

@view_config(renderer=’foo.mak’) def my_view(request):

return {’project’:’my project’}

For the above view callable to work, the following setting needs to be present in the application stanza of your configuration’s ini file:

132

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]