I have this piece of python code in gae.
def post(self):cases=self.request.get('cases')while cases:logging.info("cases: %s " % cases)case=cases.pop()
Which produces this log.
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_dispatcherreturn 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 dispatchreturn 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 dispatchreturn method(*args, **kwargs)File "/Users/brian/googleapps/scheduler/views.py", line 675, in postcase=cases.pop()
AttributeError: 'unicode' object has no attribute 'pop'
On the other hand with this almost identical code in the interactive console.
cases = [u'court1150']
while cases:case=cases.pop()print case
print cases
I get no error and the following print out.
court1150
[]
Why am I getting a unicode error in the gae launcher and how can I fix it?