Permalink
Browse files

Only try and modify template lists when they're available - not the c…

…ase when the response is pulled from cache.
  • Loading branch information...
1 parent f7341b2 commit 9d54e7abbf37fdc5a958a929495c9ee98ef98d8a @stephenmcd committed Apr 9, 2012
Showing with 12 additions and 12 deletions.
  1. +12 −12 mezzanine/core/middleware.py
@@ -38,24 +38,24 @@ def __init__(self):
class TemplateForDeviceMiddleware(object):
-
+ """
+ Inserts device-specific templates to the template list.
+ """
def process_template_response(self, request, response):
- """
- Inserts device-specific templates to the template list.
- """
- templates = templates_for_device(request, response.template_name)
- response.template_name = templates
+ if hasattr(response, "template_name"):
+ templates = templates_for_device(request, response.template_name)
+ response.template_name = templates
return response
class TemplateForHostMiddleware(object):
-
+ """
+ Inserts host-specific templates to the template list.
+ """
def process_template_response(self, request, response):
- """
- Inserts host-specific templates to the template list.
- """
- templates = templates_for_host(request, response.template_name)
- response.template_name = templates
+ if hasattr(response, "template_name"):
+ templates = templates_for_host(request, response.template_name)
+ response.template_name = templates
return response

0 comments on commit 9d54e7a

Please sign in to comment.