3

我刚刚将 GAE 升级到 1.7.6(python 2.7)。我的应用在 URL 中使用了一些西班牙语字符(例如“españa”或“cádiz”等词)。到目前为止,我与他们打交道没有任何问题。但是,升级后,我总是在我的 url 中引入特殊字符时出现错误消息,并且我的应用程序崩溃:

ProgrammingError('You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.',)
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
req.respond()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
self.server.gateway(self).respond()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
response = self.req.server.wsgi_app(self.env, self.start_response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 230, in __call__
return app(environ, start_response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/server.py", line 1114, in __call__
return self._handle_request(environ, start_response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/server.py", line 512, in _handle_request
http_version=http_version)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub.py", line 160, in WrappedMethod
return method(self, *args, **kwargs)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/logservice/logservice_stub.py", line 151, in start_request
host, start_time, method, resource, http_version))
ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

我编写了一个简单的应用程序来调试问题,但没有积极的结果:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write('Hello world!')

class MyHandler(webapp2.RequestHandler):
  def get(self, param):
    self.response.write(param)

app = webapp2.WSGIApplication([
    ('/', MainHandler),
    ('/(.*)', MyHandler)
], debug=True)

当访问 URL "/hola" 时,响应是预期的,并且浏览器显示 "hola" 词。但是,当访问“/españa”甚至“/espa%C3%B1a”时,开发服务器崩溃并出现上述错误。

请注意,该错误仅在开发中发生,我猜它与新的sqlite数据库有关;但是,在前面的示例中,我根本没有使用数据库!

有任何想法吗?请帮忙!

4

1 回答 1

2

这似乎是开发服务器的一个错误。现在最好的办法是在 GAE 错误跟踪器上为错误加注星标:GAE bug-url's with unicode characters

如果更多的人“明星”它,希望他们能更快地解决这个问题。

于 2013-03-28T19:20:06.267 回答