|
|
Choosing A Webhost: |
problem: non-ascii data and xmlrpmlib.py: msg#00025cms.opengroupware.xmlrpc.devel
Hi everybody! First I'd like to thank the responsibles for opensourcing the OGO-system. Second I'd like to thank those who are on the front line, like Helge, for their strong and ongoing support, always in a timely and contructive manner. So, let me bother you once more. Well maybe this time you'll tell me to go elsewhere with my off-topic, python-only related noise ;-). However, a number of attempts in trying to find out the deeper reason or just a working implementation failed. So here are the details. My problem seems to be in the 'xmlrpclib.py' library: See my script 'test.py' below. Effectively it reads a specific entry in the Person-Database and reinserts the very same data again. The problem appears because the city of the first address associated with my 'Test'-Person is 'São Paulo', i.e. containing an 'a' with a '~' above - a very common Portuguese accent - thus making this record one the repr. of which cannot be interpreted as Ascii-chars. Funny, but I believe that the very same situation should arise in the German language context on letters like ä, ö, and ü (umlaute). However, I did not test this. Any hints? Martin P.S.: A similar, if not the same (don't remember exactly), error occured using python V.2.2 (Mandrake 9.1) - which made me upgrade to V2.3 #------------- begin script !/usr/bin/env python # -*- coding: utf-8 -*- # createCSV.py import xmlrpclib, string, base64 import sys, codecs from pprint import * # settings url = "http://ogoserver/RPC2" login = 'root' password = 'password' if __name__ == '__main__': server = xmlrpclib.Server(url,login=login,password=password) query = { 'qualifier' : "firstname like 'Test'", 'fetchLimit' : '1', } idList = server.person.fetchIds(query) if idList: count = 1 for idBatch in range(0,len(idList),10): persons = server.person.getById(idList[idBatch:idBatch+10]) for person in persons: result = server.person.update(person) #------------ end script The call & the crash [shell]$ python test.py Traceback (most recent call last): File "test.py", line 32, in ? result = server.person.update(person) File "/ogo/scripts/xmlrpclib.py", line 829, in __call__ return self.__send(self.__name, args) File "/ogo/scripts/xmlrpclib.py", line 992, in __request request = dumps(params, methodname, encoding='utf-8') File "/ogo/scripts/xmlrpclib.py", line 771, in dumps data = m.dumps(params) File "/ogo/scripts/xmlrpclib.py", line 458, in dumps result = string.join(self.__out, "") File "/usr/lib/python2.3/string.py", line 135, in join return sep.join(words) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 16: ordinal not in range(128) [shell]$ #---------------- 'string.join' seems to be innocent: the following script works fine: #!/usr/bin/env python # coding: latin-1 import string from xmlrpclib import * s0 = 'ascii' s1 = u'São Paulo' s2 = u'S\xc3\xa3o Paulo' a = [] a.append( s0) a.append( s1) a.append( s2) print string.join(a, '|') -- OpenGroupware.org XML-RPC xmlrpc@xxxxxxxxxxxxxxxxx http://mail.opengroupware.org/mailman/listinfo/xmlrpc
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Missing Skyrix ID?, Matthias Günther |
|---|---|
| Next by Date: | Some more XML-RPC questions, Werner Schuster |
| Previous by Thread: | Re: problem: non-ascii data and xmlrpmlib.py, Helge Hess |
| Next by Thread: | problem: non-ascii data and xmlrpmlib.py, Dr. Martin Korff |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |