[Checkins] SVN: z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py fixed contentType def, add content-type header with macros

Bernd Dorn bernd.dorn at fhv.at
Wed Sep 20 13:55:20 EDT 2006


Log message for revision 70256:
  fixed contentType def, add content-type header with macros

Changed:
  U   z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py

-=-
Modified: z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py
===================================================================
--- z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py	2006-09-20 12:17:14 UTC (rev 70255)
+++ z3c.viewtemplate/trunk/src/z3c/viewtemplate/zcml.py	2006-09-20 17:55:19 UTC (rev 70256)
@@ -30,6 +30,7 @@
 from zope.publisher.interfaces.browser import IDefaultBrowserLayer
 from zope.pagetemplate.interfaces import IPageTemplate
 from zope.configuration.fields import GlobalObject
+from zope import schema
 
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
 
@@ -77,15 +78,15 @@
             default=IDefaultBrowserLayer,
             )
 
-    contentType = GlobalObject(
-            title = _(u'Content Type'),
-            description = _(u'The content type that will be set as part of '
-                             'HTTP headers'),
-            required = False,
-            default='text/html',
-            )
+    contentType = schema.BytesLine(
+        title = _(u'Content Type'),
+        description=_(u'The content type identifies the type of data.'),
+        default='text/html',
+        required=False,
+        )
 
 
+
 class TemplateFactory(object):
 
     def __init__(self, filename, macro, contentType):
@@ -98,6 +99,8 @@
                                         content_type=self.contentType)
         if self.macro is None:
             return template
+        if not request.response.getHeader("Content-Type"):
+            request.response.setHeader("Content-Type", self.contentType)
         return Macro(template, self.macro, view, request)
 
 



More information about the Checkins mailing list