Chris McDonough
2012-02-16 b2ea4c88b8b3bc9ed657160d8a888780d6c41844
Use req instead of r for #413.  It's more likely that somebody is already passing something named r, and a template may depend on its existence or nonexistence to conditionalize rendering a bit of html.
5 files modified
26 ■■■■■ changed files
CHANGES.txt 9 ●●●●● patch | view | raw | blame | history
docs/narr/renderers.rst 2 ●●● patch | view | raw | blame | history
docs/whatsnew-1.3.rst 7 ●●●● patch | view | raw | blame | history
pyramid/renderers.py 4 ●●●● patch | view | raw | blame | history
pyramid/tests/test_renderers.py 4 ●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -28,11 +28,12 @@
  more information.  This is not a new feature, it just provides an API for
  adding a traverser without needing to use the ZCA API.
- The system value ``r`` is now supplied to renderers as an alias for
- The system value ``req`` is now supplied to renderers as an alias for
  ``request``.  This means that you can now, for example, in a template, do
  ``r.route_url(...)`` instead of ``request.route_url(...)``.  This is purely
  a change to reduce the amount of typing required to reference request
  methods from within templates.
  ``req.route_url(...)`` instead of ``request.route_url(...)``.  This is
  purely a change to reduce the amount of typing required to use request
  methods and attributes from within templates.  The value ``request`` is
  still available too, this is just an alternative.
Documentation
-------------
docs/narr/renderers.rst
@@ -341,7 +341,7 @@
of the directive), ``renderer_info`` (an object containing renderer-related
information), ``context`` (the context resource of the view used to render
the template), and ``request`` (the request passed to the view used to render
the template).  ``request`` is also available as ``r`` in Pyramid 1.3+.
the template).  ``request`` is also available as ``req`` in Pyramid 1.3+.
Here's an example view configuration which uses a Chameleon ZPT renderer:
docs/whatsnew-1.3.rst
@@ -284,9 +284,12 @@
  something like "AttributeError: 'NoneType' object has no attribute
  'rfind'".
- The system value ``r`` is now supplied to renderers as an alias for
- The system value ``req`` is now supplied to renderers as an alias for
  ``request``.  This means that you can now, for example, in a template, do
  ``r.route_url(...)`` instead of ``request.route_url(...)``.
  ``req.route_url(...)`` instead of ``request.route_url(...)``.  This is
  purely a change to reduce the amount of typing required to use request
  methods and attributes from within templates.  The value ``request`` is
  still available too, this is just an alternative.
Backwards Incompatibilities
---------------------------
pyramid/renderers.py
@@ -391,7 +391,7 @@
                  'renderer_info':self,
                  'context':context,
                  'request':request,
                  'r':request,
                  'req':request,
                  }
        return self.render_to_response(response, system, request=request)
@@ -404,7 +404,7 @@
                'renderer_info':self,
                'context':getattr(request, 'context', None),
                'request':request,
                'r':request,
                'req':request,
                }
        system_values = BeforeRender(system_values, value)
pyramid/tests/test_renderers.py
@@ -485,7 +485,7 @@
                           'request': request,
                           'context': 'context',
                           'view': 'view',
                           'r': request,}
                           'req': request,}
                         )
    def test_render_explicit_registry(self):
@@ -519,7 +519,7 @@
                  'renderer_name':'loo.foo',
                  'view':None,
                  'renderer_info':helper,
                  'r':request,
                  'req':request,
                  }
        self.assertEqual(result[0], 'values')
        self.assertEqual(result[1], system)