Skip to content

Commit

Permalink
TemplateResponse properties are now called template_name and template…
Browse files Browse the repository at this point in the history
…_context - the original names (template and context) were being over-written by django.test.client.Client when running unit tests, leading to horribly difficulties debugging things
  • Loading branch information
Simon Willison committed May 23, 2009
1 parent 6bd62e8 commit 9f56abe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions django_openid/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def show_login(self, request, extra_message=None):
)

if self.password_logins_enabled:
response.template = self.login_plus_password_template
response.context.update({
response.template_name = self.login_plus_password_template
response.template_context.update({
'account_recovery': self.account_recovery_enabled and (
self.account_recovery_url or (request.path + 'recover/')
),
Expand Down
11 changes: 7 additions & 4 deletions django_openid/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
class SimpleTemplateResponse(HttpResponse):

def __init__(self, template, context, *args, **kwargs):
self.template = template
self.context = context
# These two properties were originally called 'template' and 'context'
# but django.test.client.Client was clobbering those leading to really
# tricky-to-debug problems
self.template_name = template
self.template_context = context
self.baked = False
super(SimpleTemplateResponse, self).__init__(*args, **kwargs)

Expand All @@ -26,8 +29,8 @@ def resolve_context(self, context):
return Context(context)

def render(self):
template = self.resolve_template(self.template)
context = self.resolve_context(self.context)
template = self.resolve_template(self.template_name)
context = self.resolve_context(self.template_context)
content = template.render(context)
return content

Expand Down

0 comments on commit 9f56abe

Please sign in to comment.