Nachfolgend finden Sie das vollständige Protokoll, das Problem ist in
23 dd.append(str(msg.get_json()))
Ich habe einige utf-8 von msg.get_json() zurückgegeben... Wird str() versuchen, den Parameter mit ASCII zu kodieren?
<type 'exceptions.UnicodeEncodeError'> Python 2.6.5: /usr/bin/python
Mon Nov 15 18:53:39 2010
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/usr/lib/pymodules/python2.6/flup/server/fcgi_base.py in run(self=<flup.server.fcgi_base.Request object>)
556 """Runs the handler, flushes the streams, and ends the request."""
557 try:
558 protocolStatus, appStatus = self.server.handler(self)
559 except:
560 traceback.print_exc(file=self.stderr)
protocolStatus undefined, appStatus undefined, self = <flup.server.fcgi_base.Request object>, self.server = <flup.server.fcgi.WSGIServer object>, self.server.handler = <bound method WSGIServer.handler of <flup.server.fcgi.WSGIServer object>>
/usr/lib/pymodules/python2.6/flup/server/fcgi_base.py in handler(self=<flup.server.fcgi.WSGIServer object>, req=<flup.server.fcgi_base.Request object>)
1116 try:
1117 try:
1118 result = self.application(environ, start_response)
1119 try:
1120 for data in result:
result = None, self = <flup.server.fcgi.WSGIServer object>, self.application = <function app>, environ = {'CONTENT_LENGTH': '81', 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8', 'DOCUMENT_ROOT': '/usr/local/nginx/html', 'DOCUMENT_URI': '/a.bc', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/json, text/javascript, */*', 'HTTP_ACCEPT_CHARSET': 'GB2312,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'zh-cn,zh;q=0.5', 'HTTP_CACHE_CONTROL': 'no-cache', ...}, start_response = <function start_response>
/root/bc/trunk/python/server.py in app(environ={'CONTENT_LENGTH': '81', 'CONTENT_TYPE': 'application/x-www-form-urlencoded; charset=UTF-8', 'DOCUMENT_ROOT': '/usr/local/nginx/html', 'DOCUMENT_URI': '/a.bc', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'application/json, text/javascript, */*', 'HTTP_ACCEPT_CHARSET': 'GB2312,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'zh-cn,zh;q=0.5', 'HTTP_CACHE_CONTROL': 'no-cache', ...}, start_response=<function start_response>)
125 config.dbg(cmd_name)
126 if cmd_name in cmd_map:
127 ret = cmd_map[cmd_name](q)
128 else:
129 ret = '{"' + cmd_name + '": {"result":"error"}}';
ret = 'cmd=get_room_updates&room=room2&connectionid=90125080-f0a6-11df-9dcb-0800279f1ca2', global cmd_map = {'chat_message': <function chat_message_cmd>, 'enter_room': <function enter_room_cmd>, 'get_room_updates': <function get_room_updates_cmd>, 'login_user': <function login_user_cmd>, 'register_user': <function register_user_cmd>}, cmd_name = 'get_room_updates', q = {'cmd': ['get_room_updates'], 'connectionid': ['90125080-f0a6-11df-9dcb-0800279f1ca2'], 'room': ['room2']}
/root/bc/trunk/python/server.py in get_room_updates_cmd(qs={'cmd': ['get_room_updates'], 'connectionid': ['90125080-f0a6-11df-9dcb-0800279f1ca2'], 'room': ['room2']})
88 room = config.gOnlineRooms[room_name]
89 conn = room.chat_connections[connectionid]
90 remaining = conn.get_pending_message()
91
92 return remaining
remaining = '[]', conn = <ChatConnection.ChatConnection instance>, conn.get_pending_message = <bound method ChatConnection.get_pending_message of <ChatConnection.ChatConnection instance>>
/root/bc/trunk/python/ChatConnection.py in get_pending_message(self=<ChatConnection.ChatConnection instance>)
21 for msg in self.pending_message:
22 txt = txt + msg.get_json() + ","
23 dd.append(str(msg.get_json()))
24
25 config.dbg("dd = " + str(dd))
dd = [], dd.append = <built-in method append of list object>, builtin str = <type 'str'>, msg = <Message.Message instance>, msg.get_json = <bound method Message.get_json of <Message.Message instance>>
<type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 79-80: ordinal not in range(128)
args = ('ascii', u'{"id":"168", "username":"binc2", "ctime":"2010-11-15 18:53:37.165260", "body":"\u4e2d\u56fd", "room":"room2"}', 79, 81, 'ordinal not in range(128)')
encoding = 'ascii'
end = 81
message = ''
object = u'{"id":"168", "username":"binc2", "ctime":"2010-11-15 18:53:37.165260", "body":"\u4e2d\u56fd", "room":"room2"}'
reason = 'ordinal not in range(128)'
start = 79