Skip to content

Commit

Permalink
TemplateResponse now stores Request object in _request, to avoid over…
Browse files Browse the repository at this point in the history
…-write by django.test.client.Client
  • Loading branch information
Simon Willison committed May 25, 2009
1 parent 924647b commit 8602d68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions django_openid/response.py
Expand Up @@ -67,7 +67,10 @@ def _set_content(self, value):
class TemplateResponse(SimpleTemplateResponse): class TemplateResponse(SimpleTemplateResponse):


def __init__(self, request, template, context, *args, **kwargs): 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__( super(TemplateResponse, self).__init__(
template, context, *args, **kwargs template, context, *args, **kwargs
) )
Expand All @@ -76,7 +79,7 @@ def resolve_context(self, context):
if isinstance(context, Context): if isinstance(context, Context):
return context return context
else: else:
return RequestContext(self.request, context) return RequestContext(self._request, context)


# Even less verbose alias: # Even less verbose alias:
render = TemplateResponse render = TemplateResponse
2 changes: 2 additions & 0 deletions django_openid/tests/auth_tests.py
Expand Up @@ -161,4 +161,6 @@ def testRecoverAccountByUsername(self):
self.assertEqual( self.assertEqual(
response.template_name, 'django_openid/recovery_complete.html' response.template_name, 'django_openid/recovery_complete.html'
) )
self.assertEqual(response._request.user.username, 'noopenids')



0 comments on commit 8602d68

Please sign in to comment.