summaryrefslogtreecommitdiff
path: root/repoze/bfg/chameleon_text.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-09-20 22:13:11 +0000
committerChris McDonough <chrism@agendaless.com>2009-09-20 22:13:11 +0000
commite4610566d881f707c01d266a7e336084029c83e4 (patch)
tree0a2001361b14e5b0b7521164e67560e2763e4c3c /repoze/bfg/chameleon_text.py
parent160f01439dc3e0d865b2e77bb4a9a7c9e7a16c1a (diff)
downloadpyramid-e4610566d881f707c01d266a7e336084029c83e4.tar.gz
pyramid-e4610566d881f707c01d266a7e336084029c83e4.tar.bz2
pyramid-e4610566d881f707c01d266a7e336084029c83e4.zip
- The way ``bfg_view`` declarations are scanned for has been modified.
This should have no external effects. - An object implementing the ``IRenderer`` interface (and ``ITemplateRenderer`, which is a subclass of ``IRenderer``) must now accept an extra ``system`` argument in its ``__call__`` method implementation. Values computed by the system (as opposed to by the view) are passed by the system in the ``system`` parameter, which will always be a dictionary. Keys in the dictionary include: ``view`` (the view object that returned the value), ``renderer_name`` (the template name or simple name of the renderer), ``context`` (the context object passed to the view), and ``request`` (the request object passed to the view). Previously only ITemplateRenderers received system arguments as elements inside the main ``value`` dictionary.
Diffstat (limited to 'repoze/bfg/chameleon_text.py')
-rw-r--r--repoze/bfg/chameleon_text.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/repoze/bfg/chameleon_text.py b/repoze/bfg/chameleon_text.py
index 7910746ac..9b81c4469 100644
--- a/repoze/bfg/chameleon_text.py
+++ b/repoze/bfg/chameleon_text.py
@@ -35,8 +35,13 @@ class TextTemplateRenderer(object):
def implementation(self):
return self.template
- def __call__(self, kw):
- return self.template(**kw)
+ def __call__(self, value, system):
+ try:
+ system.update(value)
+ except TypeError:
+ raise ValueError('renderer was passed non-dictionary as value')
+ result = self.template(**system)
+ return result
def get_renderer(path):
""" Return a callable ``ITemplateRenderer`` object representing a
@@ -55,7 +60,7 @@ def render_template(path, **kw):
path (may also be absolute) using the kwargs in ``*kw`` as
top-level names and return a string."""
renderer = renderer_factory(path)
- return renderer(kw)
+ return renderer(kw, {})
def render_template_to_response(path, **kw):
""" Render a ``chameleon`` text template at the package-relative
@@ -63,6 +68,6 @@ def render_template_to_response(path, **kw):
top-level names and return a Response object with the body as the
template result."""
renderer = renderer_factory(path)
- result = renderer(kw)
+ result = renderer(kw, {})
response_factory = queryUtility(IResponseFactory, default=Response)
return response_factory(result)