Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TemplateResponse now stores Request object in _request, to avoid over…

…-write by django.test.client.Client
  • Loading branch information...
commit 8602d68115c7d07ab0801905dbcdcc980fdb8eea 1 parent 924647b
Simon Willison authored
Showing with 7 additions and 2 deletions.
  1. +5 −2 django_openid/response.py
  2. +2 −0  django_openid/tests/auth_tests.py
View
7 django_openid/response.py
@@ -67,7 +67,10 @@ def _set_content(self, value):
class TemplateResponse(SimpleTemplateResponse):
def __init__(self, request, template, context, *args, **kwargs):
- self.request = request
+ # self.request gets over-written by django.test.client.Client - and
+ # unlike template_context and template_name the _request should not
+ # be considered part of the public API.
+ self._request = request
super(TemplateResponse, self).__init__(
template, context, *args, **kwargs
)
@@ -76,7 +79,7 @@ def resolve_context(self, context):
if isinstance(context, Context):
return context
else:
- return RequestContext(self.request, context)
+ return RequestContext(self._request, context)
# Even less verbose alias:
render = TemplateResponse
View
2  django_openid/tests/auth_tests.py
@@ -161,4 +161,6 @@ def testRecoverAccountByUsername(self):
self.assertEqual(
response.template_name, 'django_openid/recovery_complete.html'
)
+ self.assertEqual(response._request.user.username, 'noopenids')
+
Please sign in to comment.
Something went wrong with that request. Please try again.