Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

chameleon.core removes the meta http-equiv="content-type" tag

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


kobold at kobold

Aug 14, 2009, 5:53 AM

Post #1 of 8 (857 views)
Permalink
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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


nadako at gmail

Aug 14, 2009, 6:07 AM

Post #2 of 8 (809 views)
Permalink
Re: chameleon.core removes the meta http-equiv="content-type" tag [In reply to]

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 [at] kobold>:
> 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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


jim at zope

Aug 14, 2009, 7:54 AM

Post #3 of 8 (805 views)
Permalink
Re: chameleon.core removes the meta http-equiv="content-type" tag [In reply to]

On Fri, Aug 14, 2009 at 9:07 AM, Dan Korostelev<nadako [at] gmail> 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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


nadako at gmail

Aug 14, 2009, 8:23 AM

Post #4 of 8 (797 views)
Permalink
Re: chameleon.core removes the meta http-equiv="content-type" tag [In reply to]

2009/8/14 Jim Fulton <jim [at] zope>:
> On Fri, Aug 14, 2009 at 9:07 AM, Dan Korostelev<nadako [at] gmail> 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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


mborch at gmail

Sep 9, 2009, 5:13 AM

Post #5 of 8 (613 views)
Permalink
Re: chameleon.core removes the meta http-equiv="content-type" tag [In reply to]

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

_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


sidnei.da.silva at gmail

Sep 9, 2009, 7:00 AM

Post #6 of 8 (609 views)
Permalink
Re: chameleon.core removes the meta http-equiv="content-type" tag [In reply to]

On Wed, Sep 9, 2009 at 9:13 AM, Malthe Borch<mborch [at] gmail> 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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


fdrake at gmail

Sep 9, 2009, 7:25 AM

Post #7 of 8 (612 views)
Permalink
Re: chameleon.core removes the meta http-equiv="content-type" tag [In reply to]

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
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


mborch at gmail

Sep 10, 2009, 7:01 AM

Post #8 of 8 (609 views)
Permalink
Re: chameleon.core removes the meta http-equiv="content-type" tag [In reply to]

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

_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
https://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.