私はgaeにこのpythonコードを持っています。
def post(self):
cases=self.request.get('cases')
while cases:
logging.info("cases: %s " % cases)
case=cases.pop()
このログを生成します。
INFO 2012-09-19 20:23:50,690 views.py:674] cases: [u'court1150']
ERROR 2012-09-19 20:23:50,690 webapp2.py:1553] 'unicode' object has no attribute 'pop'
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1536, in __call__
rv = self.handle_exception(request, response, e)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1530, in __call__
rv = self.router.dispatch(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/Users/brian/googleapps/scheduler/views.py", line 675, in post
case=cases.pop()
AttributeError: 'unicode' object has no attribute 'pop'
一方、インタラクティブ コンソールでは、このほぼ同じコードを使用します。
cases = [u'court1150']
while cases:
case=cases.pop()
print case
print cases
エラーは発生せず、次の出力が表示されます。
court1150
[]
gae ランチャーで Unicode エラーが発生するのはなぜですか? どうすれば修正できますか?