[Zope-dev] Content Type Meta tag stripping in zope.pagetemplate

Miano Njoka mianonjoka at gmail.com
Fri Feb 24 08:47:39 UTC 2012


On Thu, Feb 23, 2012 at 2:44 PM, Fred Drake <fred at fdrake.net> wrote:
> On Thu, Feb 23, 2012 at 2:54 AM, Miano Njoka <mianonjoka at gmail.com> wrote:
>> Yes, this is true, but why strip out the meta tag from the resulting HTML?
>
> Two reasons:
>
> 1. It may be incorrect.
>
> 2. If multiple templates are used to construct a response, different
>   values may be included from each template, which may be inconsistent.
>

The code as it is now does not take this into account. It parses the
meta content type tag from all the templates passed to it and the
content type header sent in the response will be that of the last
template processed.


> Since the meta element is unnecessary, it seemed better to leave it out
> of the result,

While it is not essential, it is necessary in some cases where the
finished document will be read from disk or is used by other
applications eg. Deliverance[http://packages.python.org/Deliverance/].
In fact w3c's HTML validator throws a warning that one should declare
the character encoding in the document itself if it is missing.

> and rely on other components to render the correct values
> without requiring them to insert correct values into the rendered template.

Rather than removing the meta tag, I think its less complicated to
leave it in the finished HTML and let the developer fix any
inconsistencies that may arise.


More information about the Zope-Dev mailing list