Hi guys, I'm having trouble installing and using the japanese codecs (from http://www.python.jp/pub/JapaneseCodecs )with Zope on a shared host. I just can't seem to get the encodings available for the python used by the Zope install. Or, that is, I have installed the codecs and can 'import japanese' but whenever I try something like the following in a Python script: ---- import japanese #works print japanese #<module 'japanese' from '/home/USERNAME/webapps/zope/zinstance/parts/instance/lib/python/japanese/__init__.pyc'> #however there's nothing in /home/USERNAME/webapps/zope/zinstance/parts/instance/lib/python/ except a README.txt saying this directory will hold additional installed packages... should there be something here? text = 'blah blah' #okay text = unicode(text, 'utf-8') #okay text = text.encode('japanese.iso-2022-jp') #fails with lookuperror ---- LookupError: unknown encoding: japanese.iso-2022-jp This error also happens in an External Method. I have previously installed these codecs on an older version of Zope (Zope-2.7.0) (old-style instance) and Python (2.3.4) on a dedicated server, but am at a loss as to how to go about it with a Zope buildout on a shared host (Zope 2.10.9 on Python 2.4.3). The guys at Webfaction are also at a loss, and suggested I ask here. Anyone have any ideas? Aaron
+-------[ Aaron Maupin ]---------------------- | Hi guys, | | I'm having trouble installing and using the japanese codecs (from | http://www.python.jp/pub/JapaneseCodecs )with Zope on a shared host. I | just can't seem to get the encodings available for the python used by | the Zope install. [snip] | ---- | import japanese #works | | print japanese | #<module 'japanese' from | '/home/USERNAME/webapps/zope/zinstance/parts/instance/lib/python/japanese/__init__.pyc'> | #however there's nothing in | /home/USERNAME/webapps/zope/zinstance/parts/instance/lib/python/ except | a README.txt saying this directory will hold additional installed | packages... should there be something here? | | text = 'blah blah' #okay | text = unicode(text, 'utf-8') #okay | text = text.encode('japanese.iso-2022-jp') #fails with lookuperror Tried simply; text.encode('iso-2022-jp') ? -- Andrew Milton akm@theinternet.com.au
+-------[ Aaron Maupin ]---------------------- | Andrew Milton wrote: | | >Tried simply; text.encode('iso-2022-jp') ? | | Yes, I've tried that. I get 'unknown encoding: iso-2022-jp' "japanese.python.iso-2022-jp" -- Andrew Milton akm@theinternet.com.au
Andrew Milton wrote:
+-------[ Aaron Maupin ]---------------------- | Andrew Milton wrote: | | >Tried simply; text.encode('iso-2022-jp') ? | | Yes, I've tried that. I get 'unknown encoding: iso-2022-jp'
"japanese.python.iso-2022-jp"
Not sure why that would work, but I just tried it and it didn't. Thanks for the suggestion, though.
+-------[ Aaron Maupin ]---------------------- | Andrew Milton wrote: | >+-------[ Aaron Maupin ]---------------------- | >| Andrew Milton wrote: | >| | >| >Tried simply; text.encode('iso-2022-jp') ? | >| | >| Yes, I've tried that. I get 'unknown encoding: iso-2022-jp' | > | >"japanese.python.iso-2022-jp" | | Not sure why that would work That's what the included test cases use... -- Andrew Milton akm@theinternet.com.au
Perhaps I should also mention that I can log into the server, open up a python console, and type:
import japanese text = 'blahblah' text = unicode(text, 'utf-8') text = text.encode('japanese.iso-2022-jp')
with no problems. 'japanese' is installed in /usr/lib/python2.4/site-packages/ I removed my recent /home/USERNAME/lib/python2.4 'japanese' install and now 'import japanese', 'print japanese' within Zope reveals that Zope is using the same /usr/lib/python2.4/site-packages/japanese as the python console. However I still get an encoding error in Zope Python scripts or External Methods with the above code... code that works fine in the Python console. Is there some sort of security within Zope that's stopping me from accessing the encoding? Aaron
+-------[ Aaron Maupin ]---------------------- | Perhaps I should also mention that I can log into the server, open up a | python console, and type: | | >>> import japanese | >>> text = 'blahblah' | >>> text = unicode(text, 'utf-8') | >>> text = text.encode('japanese.iso-2022-jp') | | with no problems. | | 'japanese' is installed in /usr/lib/python2.4/site-packages/ | | I removed my recent /home/USERNAME/lib/python2.4 'japanese' install and | now 'import japanese', 'print japanese' within Zope reveals that Zope is | using the same /usr/lib/python2.4/site-packages/japanese as the python | console. | | However I still get an encoding error in Zope Python scripts or External | Methods with the above code... code that works fine in the Python console. | | Is there some sort of security within Zope that's stopping me from | accessing the encoding? try doing import japanese.aliases and see if that causes an error that's otherwise being hidden. -- Andrew Milton akm@theinternet.com.au
Andrew Milton wrote:
try doing
import japanese.aliases
and see if that causes an error that's otherwise being hidden.
Hmmm. Within a Python script I get asked for my Zope username and password again, which isn't accepted, and then a 'You are not allowed to access 'aliases' in this context' Within an external method, japanese.aliases imports fine: <module 'japanese.aliases' from '/usr/lib/python2.4/site-packages/japanese/aliases/__init__.pyc'> but I still get a lookup error for the encoding. Aaron
Hi, Recent python includes japanese codecs so that you don't have to install JapaneseCodecs any longer. If you use python2.1, it is needed.
import codecs codecs.lookup('iso-2022-jp') <codecs.CodecInfo object for encoding iso2022_jp at 0x7fb1cd7a38d8>
Regards, Yusei On Sat, 27 Feb 2010 04:27:23 +0900 Aaron Maupin <maupin@pastrytech.com> wrote:
Hi guys,
I'm having trouble installing and using the japanese codecs (from http://www.python.jp/pub/JapaneseCodecs )with Zope on a shared host. I just can't seem to get the encodings available for the python used by the Zope install.
Or, that is, I have installed the codecs and can 'import japanese' but whenever I try something like the following in a Python script:
---- import japanese #works
print japanese #<module 'japanese' from '/home/USERNAME/webapps/zope/zinstance/parts/instance/lib/python/japanese/__init__.pyc'> #however there's nothing in /home/USERNAME/webapps/zope/zinstance/parts/instance/lib/python/ except a README.txt saying this directory will hold additional installed packages... should there be something here?
text = 'blah blah' #okay text = unicode(text, 'utf-8') #okay text = text.encode('japanese.iso-2022-jp') #fails with lookuperror ----
LookupError: unknown encoding: japanese.iso-2022-jp
This error also happens in an External Method.
I have previously installed these codecs on an older version of Zope (Zope-2.7.0) (old-style instance) and Python (2.3.4) on a dedicated server, but am at a loss as to how to go about it with a Zope buildout on a shared host (Zope 2.10.9 on Python 2.4.3).
The guys at Webfaction are also at a loss, and suggested I ask here. Anyone have any ideas?
Aaron
_______________________________________________ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )
-- Yusei TAHARA <yusei@nexedi.com>
Yusei TAHARA wrote:
Hi,
Recent python includes japanese codecs so that you don't have to install JapaneseCodecs any longer. If you use python2.1, it is needed.
import codecs codecs.lookup('iso-2022-jp') <codecs.CodecInfo object for encoding iso2022_jp at 0x7fb1cd7a38d8>
Thanks Yusei! The above works within the Python console, but within a Zope Python script I get repeated username/password requests, finally failing with a 'You are not allowed to access 'lookup' in this context'. Within a Zope External Method I get 'unknown encoding: iso-2022-jp' However I just tried 'iso2022_jp' within an External Method and that worked. 'iso-2022-jp' is supposed to be an accepted alias of 'iso2022_jp' but apparently the external method is unable to find it using the alias... Anyway, hopefully now I'll be able to convert Japanese text in utf-8 to iso-2022-jp! Thanks! Aaron
Hi, On Mon, 01 Mar 2010 06:35:51 +0900 Aaron Maupin <maupin@pastrytech.com> wrote:
Yusei TAHARA wrote:
Hi,
Recent python includes japanese codecs so that you don't have to install JapaneseCodecs any longer. If you use python2.1, it is needed.
import codecs codecs.lookup('iso-2022-jp') <codecs.CodecInfo object for encoding iso2022_jp at 0x7fb1cd7a38d8>
Thanks Yusei!
The above works within the Python console, but within a Zope Python script I get repeated username/password requests, finally failing with a 'You are not allowed to access 'lookup' in this context'.
Within a Zope External Method I get 'unknown encoding: iso-2022-jp'
However I just tried 'iso2022_jp' within an External Method and that worked. 'iso-2022-jp' is supposed to be an accepted alias of 'iso2022_jp' but apparently the external method is unable to find it using the alias...
Anyway, hopefully now I'll be able to convert Japanese text in utf-8 to iso-2022-jp! Thanks!
OK, good to hear that. FYI, PythonScript on Zope is not normal python. It is a restricted python environment. If you want to import and use any python modules except very basic ones like string module, you need to add a security declaration. See Products/PythonScripts/module_access_examples.py. Regards, -- Yusei TAHARA <yusei@nexedi.com>
participants (3)
-
Aaron Maupin -
Andrew Milton -
Yusei TAHARA