chameleon.core removes the meta http-equiv="content-type" tag
Hello, I hope this is the right mailing list for such a question. Why does chameleon.core removes the meta tag http-equiv="content-type" from the output? In template.py, line 286: # Look for an encoding specification in the meta tag match = utils.re_meta.search(body) if match is not None: content_type, encoding = match.groups() # TODO: Shouldn't <meta>/<?xml?> stripping # be in PageTemplate.__call__()? body = utils.re_meta.sub("", body) else: content_type = None encoding = config.DEFAULT_ENCODING I couldn't find the explanation anywhere in the source code nor in the documentation. Thanks, Fabio
Oh, thanks that you reminded me of that :)) This looks like it migrated from zope.pagetemplate. That shameless removal of content from my template annoyed me as well some time ago, so at last I monkey-patched that method in zope.pagetemplate. I think, we should remove that behaviour from both zope.pagetemplate and chameleon.core, because it's developer' prerogative to decide what to keep and what to remove from the rendered page, not the templating system's. If noone objects, I'll fix it in zope.pagetemplate. 2009/8/14 Fabio Tranchitella <kobold@kobold.it>:
I hope this is the right mailing list for such a question. Why does chameleon.core removes the meta tag http-equiv="content-type" from the output?
In template.py, line 286:
# Look for an encoding specification in the meta tag match = utils.re_meta.search(body) if match is not None: content_type, encoding = match.groups() # TODO: Shouldn't <meta>/<?xml?> stripping # be in PageTemplate.__call__()? body = utils.re_meta.sub("", body) else: content_type = None encoding = config.DEFAULT_ENCODING
I couldn't find the explanation anywhere in the source code nor in the documentation.
-- WBR, Dan Korostelev
On Fri, Aug 14, 2009 at 9:07 AM, Dan Korostelev<nadako@gmail.com> wrote:
Oh, thanks that you reminded me of that :))
This looks like it migrated from zope.pagetemplate. That shameless removal of content from my template annoyed me as well some time ago, so at last I monkey-patched that method in zope.pagetemplate. I think, we should remove that behaviour from both zope.pagetemplate and chameleon.core, because it's developer' prerogative to decide what to keep and what to remove from the rendered page, not the templating system's. If noone objects, I'll fix it in zope.pagetemplate.
Please get Fred Drake's review before removing this from zope.pagetemplate. Jim -- Jim Fulton
2009/8/14 Jim Fulton <jim@zope.com>:
On Fri, Aug 14, 2009 at 9:07 AM, Dan Korostelev<nadako@gmail.com> wrote:
Oh, thanks that you reminded me of that :))
This looks like it migrated from zope.pagetemplate. That shameless removal of content from my template annoyed me as well some time ago, so at last I monkey-patched that method in zope.pagetemplate. I think, we should remove that behaviour from both zope.pagetemplate and chameleon.core, because it's developer' prerogative to decide what to keep and what to remove from the rendered page, not the templating system's. If noone objects, I'll fix it in zope.pagetemplate.
Please get Fred Drake's review before removing this from zope.pagetemplate.
According to SVN history, the meta tag stripping was added 4 years ago by Dmitry Vasiliev, not Fred Drake. Or was that done after Fred's approval? :) Okay, anyway, I'll wait for him to return from vacation. -- WBR, Dan Korostelev
Fabio Tranchitella wrote:
I hope this is the right mailing list for such a question. Why does chameleon.core removes the meta tag http-equiv="content-type" from the output?
I have no idea why; I've asked Sidnei to clarify that particular changeset in Chameleon (although I suspect it was just carried over as-is from ``zope.pagetemplate``). \malthe
On Wed, Sep 9, 2009 at 9:13 AM, Malthe Borch<mborch@gmail.com> wrote:
Fabio Tranchitella wrote:
I hope this is the right mailing list for such a question. Why does chameleon.core removes the meta tag http-equiv="content-type" from the output?
I have no idea why; I've asked Sidnei to clarify that particular changeset in Chameleon (although I suspect it was just carried over as-is from ``zope.pagetemplate``).
As far as I remember, it was just carried over as-is. Some (local) tests that expected it to be gone were failing with chameleon. -- Sidnei
The <meta http-equiv="content-type" content="..."> is used to identify the encoding of the file providing the template. This has nothing to do with the encoding of the output resource, which is determined by the application. In the case of the Zope publisher, Unicode output from the template is converted to UTF-8 by default, and the charset is set appropriately for text/* content types. This gets to the basic problem that templates have both input and output concerns, and there's currently no clean way to separate the two without additional syntax or metadata support. There's no one way to handle this; zope.pagetemplate.pagetemplatefile contains specific choices which made sense at the time; I think these are still reasonable choices. Existing applications may well require the current behavior, so it's unreasonable to change that, regardless of how attractive a new set of choices may appear. The right way to make new choices is to create a new class that embodies those choices, or which allows runtime configuration, and use that as appropriate. -Fred -- Fred L. Drake, Jr. <fdrake at gmail.com> "Chaos is the score upon which reality is written." --Henry Miller
Fabio Tranchitella wrote:
# TODO: Shouldn't <meta>/<?xml?> stripping # be in PageTemplate.__call__()? body = utils.re_meta.sub("", body)
This snippet was removed from ``chameleon.core`` in r6505. \malthe
participants (6)
-
Dan Korostelev -
Fabio Tranchitella -
Fred Drake -
Jim Fulton -
Malthe Borch -
Sidnei da Silva