[Checkins] SVN: z3c.pt/trunk/ Check that we have a non-trivial response-object before trying to set the content type.

Malthe Borch mborch at gmail.com
Mon May 11 02:55:54 EDT 2009


Log message for revision 99834:
  Check that we have a non-trivial response-object before trying to set the content type.

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/pagetemplate.py

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2009-05-11 06:54:42 UTC (rev 99833)
+++ z3c.pt/trunk/CHANGES.txt	2009-05-11 06:55:54 UTC (rev 99834)
@@ -1,6 +1,9 @@
 Changelog
 ---------
 
+- Check that we have a non-trivial response-object before trying to
+  set the content type. [malthe]
+
 - Wrap ``sys.modules`` dictionary in an "opaque" dictionary class,
   such that the representation string does not list all loaded
   modules. [malthe]

Modified: z3c.pt/trunk/src/z3c/pt/pagetemplate.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2009-05-11 06:54:42 UTC (rev 99833)
+++ z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2009-05-11 06:55:54 UTC (rev 99834)
@@ -107,8 +107,9 @@
 
             if request is not None and not isinstance(request, basestring):
                 content_type = self.content_type or 'text/html'
-                if not request.response.getHeader("Content-Type"):
-                    request.response.setHeader(
+                response = request.response
+                if response and not response.getHeader("Content-Type"):
+                    response.setHeader(
                         "Content-Type", content_type)
 
             if macro is None:



More information about the Checkins mailing list