RE: [Zope] utf-8 problem in Zope when using Localizer
Doyon, Jean-Francois wrote at 2007-8-24 09:36 -0400: > ... >setdefaultencoding() is apparently frowned upon ... Not sure why though. Occasionally, a package writer expects that "str" converts to ASCII, such that try: ascii = str(unicodeStr) except UnicodeError: # non ascii can be used to check for ASCIIness. Of course, this is true only when the defaultencoding is "ASCII". Fortunately, "unicode(unicodeStr, 'ascii')" can safely be used instead. The code above actually occured in Python's "xmlrpclib". When I reported the bug, people said we should eliminate "setdefaultencoding" But, then, they nevertheless fixed the bug... -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] utf-8 problem in Zope when using Localizer
Patrick Ulmer wrote at 2007-8-24 10:26 +0200: >I think I solved the problem. > > > >works. I read some further and found out that I should use something like > >import sys >sys.setdefaultencoding('utf-8') > >I set it global in sitecustomize.py under /usr/lib/python2.4/site-packages and >then > > > > >works. Now I only must find the right place for setdefaultencoding() so >it only affect my zope-instance. "$INSTANCE_HOME/lib/python" would be a good place for the "site-customize.py". -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Global Variable In PT
[EMAIL PROTECTED] wrote at 2007-8-23 13:47 -0400: > ... >I have this code (editing out the extraneous) at the beginning of a page: > > tal:define="newRow string:yes"> > >After calling some other variables (specifically rotating through a changing >¨item¨ (for item in items...)), I try and change newRow: > > > >Then I try and call newRow: > > > >But it gives me the original value. Now, if I edit the page like this: > > > > This means, you already have found a solution to your problem: Use "global" consistently for your variables. I think, I also have read a specification how "global" and "local" definitions for the same variable interact. When I remember right (but I am not sure), then what you is is consistent with the specification. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] utf-8 problem in Zope when using Localizer
If you can, I would strongly recommend using the Zope3/Five way of doing translations and i18n in general! See here: http://worldcookery.com/files/fivei18n/ http://codespeak.net/z3/five/i18n.html I've made my site fully internationalized, localized and utf-8 using this method without resorting to any "trickery". setdefaultencoding() is apparently frowned upon ... Not sure why though. Good luck! J.F. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Patrick Ulmer Sent: August 24, 2007 04:27 To: zope@zope.org Subject: Re: [Zope] utf-8 problem in Zope when using Localizer Hi, I think I solved the problem. works. I read some further and found out that I should use something like import sys sys.setdefaultencoding('utf-8') I set it global in sitecustomize.py under /usr/lib/python2.4/site-packages and then works. Now I only must find the right place for setdefaultencoding() so it only affect my zope-instance. Regars Patrick Patrick Ulmer schrieb: > I think it's the right way for a solution. Now my page is utf-8, but > if the string returned from MessageCatalog have utf-8 chars and not > online chars in ascii range I get this error-message: > > Error Type: UnicodeEncodeError > Error Value: 'ascii' codec can't encode character u'\xf4' in position > 3: ordinal not in range(128) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] utf-8 problem in Zope when using Localizer
Hi, I think I solved the problem. works. I read some further and found out that I should use something like import sys sys.setdefaultencoding('utf-8') I set it global in sitecustomize.py under /usr/lib/python2.4/site-packages and then works. Now I only must find the right place for setdefaultencoding() so it only affect my zope-instance. Regars Patrick Patrick Ulmer schrieb: > I think it's the right way for a solution. Now my page is utf-8, but if > the string returned from MessageCatalog have utf-8 chars and not online > chars in ascii range I get this error-message: > > Error Type: UnicodeEncodeError > Error Value: 'ascii' codec can't encode character u'\xf4' in position > 3: ordinal not in range(128) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] utf-8 problem in Zope when using Localizer
>> I have checked it but it is the same problem. Browser is encoding in >> utf-8 correct, but the result (html sourcecode from zope) is not utf-8 >> anymore after inserting and I >> don't know why it changed. How can a dtml-var-tag changed the encoding >> for the document? >> > > What about > > > > Use _.str() solves many potential problems I think it's the right way for a solution. Now my page is utf-8, but if the string returned from MessageCatalog have utf-8 chars and not online chars in ascii range I get this error-message: *Error Type: UnicodeEncodeError* *Error Value: 'ascii' codec can't encode character u'\xf4' in position 3: ordinal not in range(128)* Regards Patrick ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] utf-8 problem in Zope when using Localizer
--On 24. August 2007 09:36:30 +0200 Jaroslav Lukesh <[EMAIL PROTECTED]> wrote: - Original Message - From: "Patrick Ulmer" <[EMAIL PROTECTED]> The http-equiv tag means not much to browser. Try setting the content-type including the charset within the HTTP response (REQUEST.RESPONSE.setHeader(...)). I have checked it but it is the same problem. Browser is encoding in utf-8 correct, but the result (html sourcecode from zope) is not utf-8 anymore after inserting and I don't know why it changed. How can a dtml-var-tag changed the encoding for the document? What about Use _.str() solves many potential problems That's the mallet method. -aj pgpNZuRDJFJSt.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] utf-8 problem in Zope when using Localizer
- Original Message - From: "Patrick Ulmer" <[EMAIL PROTECTED]> The http-equiv tag means not much to browser. Try setting the content-type including the charset within the HTTP response (REQUEST.RESPONSE.setHeader(...)). I have checked it but it is the same problem. Browser is encoding in utf-8 correct, but the result (html sourcecode from zope) is not utf-8 anymore after inserting and I don't know why it changed. How can a dtml-var-tag changed the encoding for the document? What about Use _.str() solves many potential problems Regards JL. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] utf-8 problem in Zope when using Localizer
Hi, >> 4. I insert html-code and some russian chars for testing >> >> >> >> >> >> >>...russian chars... >> >> >> >> After Saving all looks great in ZMI and also in my webbrowser. >> >> 5. Now I add one line to use a MessageCatalog: >> >> >> >> After that, all of my utf-8-chars are broken in my webbrowser. I check >> browser-encoding and it is still utf-8. In ZMI my "DTML Document" looks >> good. This line must switch something in the output-encoding in the >> internal page-render (I don't know, how to better explain it). Is this >> an error in Localizer or in Zope or have I overlook a fault? >> > > The http-equiv tag means not much to browser. Try setting the > content-type > including the charset within the HTTP response > (REQUEST.RESPONSE.setHeader(...)). I have checked it but it is the same problem. Browser is encoding in utf-8 correct, but the result (html sourcecode from zope) is not utf-8 anymore after inserting and I don't know why it changed. How can a dtml-var-tag changed the encoding for the document? Thanks, Patrick ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )