summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-02-15 22:06:30 -0500
committerChris McDonough <chrism@plope.com>2012-02-15 22:06:30 -0500
commitb2ea4c88b8b3bc9ed657160d8a888780d6c41844 (patch)
tree39086f37dc8cf920e278830321310947e05c5b6f
parent2a75f355dcf60ce1c8f537b4dfa35dbc15554661 (diff)
downloadpyramid-b2ea4c88b8b3bc9ed657160d8a888780d6c41844.tar.gz
pyramid-b2ea4c88b8b3bc9ed657160d8a888780d6c41844.tar.bz2
pyramid-b2ea4c88b8b3bc9ed657160d8a888780d6c41844.zip
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.
-rw-r--r--CHANGES.txt9
-rw-r--r--docs/narr/renderers.rst2
-rw-r--r--docs/whatsnew-1.3.rst7
-rw-r--r--pyramid/renderers.py4
-rw-r--r--pyramid/tests/test_renderers.py4
5 files changed, 15 insertions, 11 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 93ba8a199..26d547ae6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -28,11 +28,12 @@ Features
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
-------------
diff --git a/docs/narr/renderers.rst b/docs/narr/renderers.rst
index 1622f1f29..1f1b1943b 100644
--- a/docs/narr/renderers.rst
+++ b/docs/narr/renderers.rst
@@ -341,7 +341,7 @@ template are ``renderer_name`` (the string used in the ``renderer`` attribute
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:
diff --git a/docs/whatsnew-1.3.rst b/docs/whatsnew-1.3.rst
index c4bde2b54..a27ef6af9 100644
--- a/docs/whatsnew-1.3.rst
+++ b/docs/whatsnew-1.3.rst
@@ -284,9 +284,12 @@ Minor Feature Additions
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
---------------------------
diff --git a/pyramid/renderers.py b/pyramid/renderers.py
index a94d86e20..14941c61a 100644
--- a/pyramid/renderers.py
+++ b/pyramid/renderers.py
@@ -391,7 +391,7 @@ class RendererHelper(object):
'renderer_info':self,
'context':context,
'request':request,
- 'r':request,
+ 'req':request,
}
return self.render_to_response(response, system, request=request)
@@ -404,7 +404,7 @@ class RendererHelper(object):
'renderer_info':self,
'context':getattr(request, 'context', None),
'request':request,
- 'r':request,
+ 'req':request,
}
system_values = BeforeRender(system_values, value)
diff --git a/pyramid/tests/test_renderers.py b/pyramid/tests/test_renderers.py
index 2c27c6c29..b32e68e25 100644
--- a/pyramid/tests/test_renderers.py
+++ b/pyramid/tests/test_renderers.py
@@ -485,7 +485,7 @@ class TestRendererHelper(unittest.TestCase):
'request': request,
'context': 'context',
'view': 'view',
- 'r': request,}
+ 'req': request,}
)
def test_render_explicit_registry(self):
@@ -519,7 +519,7 @@ class TestRendererHelper(unittest.TestCase):
'renderer_name':'loo.foo',
'view':None,
'renderer_info':helper,
- 'r':request,
+ 'req':request,
}
self.assertEqual(result[0], 'values')
self.assertEqual(result[1], system)