manage_changeProperties has strange side effect on response Content-Type.
This gave me such a headache today, that I thought I ought to mention it. All my pages normally have a content-type of ISO-8859-1 I have not spent much thought on this, it has just worked nicely like that. Today I had a page that called a python script, that even when I made it return an empty string, changed the content-type of my page to utf-8. I finally tracked it down to this difference: item.manage_changeProperties({'title':'Hustype'}) gives utf-8. item.manage_changeProperties(title='Hustype') leaves ISO-8859-1 intact. WTF is that? Now you have been warned :) Regards Gaute Amundsen
--On 16. Juni 2006 13:05:09 +0200 Gaute Amundsen <gaute@div.org> wrote:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8.
This makes less sense. You're passing an ASCII string which has the same representation in UTF-8..so why should this be a utf-8 string?
item.manage_changeProperties(title='Hustype') leaves ISO-8859-1 intact.
see above.
WTF is that?
Your example is just poor.
Now you have been warned :)
Another try? -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: info@zopyx.com - Phone +49 - 7071 - 793376 E-Publishing, Python, Zope & Plone development, Consulting
On Friday 16 June 2006 13:14, Andreas Jung wrote:
--On 16. Juni 2006 13:05:09 +0200 Gaute Amundsen <gaute@div.org> wrote:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8.
This makes less sense. You're passing an ASCII string which has the same representation in UTF-8..so why should this be a utf-8 string?
You ask me? I ask you! (I think the string is rather irrelevant here, It's the form of the agument..)
item.manage_changeProperties(title='Hustype') leaves ISO-8859-1 intact.
see above.
WTF is that?
Your example is just poor.
It's all there is. Deal with it. (if you like)
Now you have been warned :)
Another try?
Yes, please do. G.
--On 16. Juni 2006 13:31:35 +0200 Gaute Amundsen <gaute@div.org> wrote:
On Friday 16 June 2006 13:14, Andreas Jung wrote:
--On 16. Juni 2006 13:05:09 +0200 Gaute Amundsen <gaute@div.org> wrote:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8.
This makes less sense. You're passing an ASCII string which has the same representation in UTF-8..so why should this be a utf-8 string?
You ask me? I ask you!
Strange opionion. Again: an ASCII string will *never* mutate to something else. It's representation in ISO-XXXXX, UTF-8 or whatever is *always* the same as the ASCII representation....in addition it is not reproducable.
Another try?
Yes, go ahead and file a bug report to the Zope Collector including a reasonable description of the problem and a description how to reproduce it. -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: info@zopyx.com - Phone +49 - 7071 - 793376 E-Publishing, Python, Zope & Plone development, Consulting
Gaute Amundsen schrieb:
This gave me such a headache today, that I thought I ought to mention it.
All my pages normally have a content-type of ISO-8859-1 I have not spent much thought on this, it has just worked nicely like that.
Today I had a page that called a python script, that even when I made it return an empty string, changed the content-type of my page to utf-8.
I finally tracked it down to this difference:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8. item.manage_changeProperties(title='Hustype') leaves ISO-8859-1 intact.
WTF is that?
My guess would be the dict-argument is used in place of REQUEST and therefore sets some default encoding in request - which it certainly acquires. But this is all looking into the crystal sphere because I not yet have time to actually look at the source - otoh it would be of great help if you provide: 1.) the excat zope version 2.) manage_page_charset settings 3.) default encodings set in zope.conf etc. Regards Tino Wildenhain
--On 16. Juni 2006 13:39:03 +0200 Tino Wildenhain <tino@wildenhain.de> wrote:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8. item.manage_changeProperties(title='Hustype') leaves ISO-8859-1 intact.
WTF is that?
My guess would be the dict-argument is used in place of REQUEST and therefore sets some default encoding in request - which it certainly acquires.
'Hustype' is pure ASCII...this will *always* have the same encoding in almost all encodings (except in Klingon). -aj
--On 16. Juni 2006 13:42:40 +0200 Andreas Jung <lists@zopyx.com> wrote:
--On 16. Juni 2006 13:39:03 +0200 Tino Wildenhain <tino@wildenhain.de> wrote:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8. item.manage_changeProperties(title='Hustype') leaves ISO-8859-1 intact.
WTF is that?
My guess would be the dict-argument is used in place of REQUEST and therefore sets some default encoding in request - which it certainly acquires.
'Hustype' is pure ASCII...this will *always* have the same encoding in almost all encodings (except in Klingon).
Sorry, I was misreading your posting. But to some degree it looks odd..put it in the Zope bugtracker otherwise it will be forgotten! -aj
Hi Andreas, Andreas Jung wrote:
'Hustype' is pure ASCII...this will *always* have the same encoding in almost all encodings (except in Klingon).
[klingon] ghaH ghItlhta' Daq [ASCII] ;-) -- Regards, PhilK "Human language continually changes, innit." - Stephen Juan
On Friday 16 June 2006 13:39, Tino Wildenhain wrote:
Gaute Amundsen schrieb: <snip>
item.manage_changeProperties({'title':'Hustype'}) gives utf-8. item.manage_changeProperties(title='Hustype') leaves ISO-8859-1 intact.
WTF is that?
My guess would be the dict-argument is used in place of REQUEST and therefore sets some default encoding in request - which it certainly acquires.
But this is all looking into the crystal sphere because I not yet have time to actually look at the source - otoh it would be of great help if you provide:
1.) the excat zope version 2.) manage_page_charset settings 3.) default encodings set in zope.conf etc.
Regards Tino Wildenhain
That's making more sense :) I was suspecting something like that. I should have learned to ignore Andreas Jung's arrogant misreadings last time. :( 1) Zope Version: (unreleased version, 2.7.0-based, python 2.3.3, linux2) 2) A few quick googles was not able to reveal where I can get hold of the manage_page_charset settings... 3) No mention of "char" or "encode" in zope.conf G.
Gaute Amundsen wrote at 2006-6-16 13:05 +0200:
All my pages normally have a content-type of ISO-8859-1 I have not spent much thought on this, it has just worked nicely like that.
Today I had a page that called a python script, that even when I made it return an empty string, changed the content-type of my page to utf-8.
I finally tracked it down to this difference:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8.
"manage_changeProperties" has two usage modes: one for programmatic use and one for ZMI use. As many other management functions, it distinquishes between the two mode by checking whether "REQUEST" is "None". When used from the ZMI, the ZPublisher passes in "REQUEST" which therefore is not None. You passed a positional argument to "manage_changeProperties" which it interprets as "REQUEST". Therefore, it thinks it were used from the ZMI and uses the "management_charset" (or something like that) as encoding. Use "manage_changeProperties(**dict)" instead of "manage_changeProperties(dict)" to avoid this problem. -- Dieter
On Friday 16 June 2006 20:28, Dieter Maurer wrote:
Gaute Amundsen wrote at 2006-6-16 13:05 +0200:
All my pages normally have a content-type of ISO-8859-1 I have not spent much thought on this, it has just worked nicely like that.
Today I had a page that called a python script, that even when I made it return an empty string, changed the content-type of my page to utf-8.
I finally tracked it down to this difference:
item.manage_changeProperties({'title':'Hustype'}) gives utf-8.
"manage_changeProperties" has two usage modes: one for programmatic use and one for ZMI use. As many other management functions, it distinquishes between the two mode by checking whether "REQUEST" is "None". When used from the ZMI, the ZPublisher passes in "REQUEST" which therefore is not None.
You passed a positional argument to "manage_changeProperties" which it interprets as "REQUEST". Therefore, it thinks it were used from the ZMI and uses the "management_charset" (or something like that) as encoding.
Use "manage_changeProperties(**dict)" instead of "manage_changeProperties(dict)" to avoid this problem.
Makes perfect sense when you put it like that, I guess. But I woluld never have guessed it from reading the APIdoc... I would have liked to ad a comment about this in the doc, but that function seems to be out of order for both FF, and Opera. Thanks anyway. Gaute
participants (5)
-
Andreas Jung -
Dieter Maurer -
Gaute Amundsen -
Philip Kilner -
Tino Wildenhain