2013년 10월 13일 일요일

AssertionError: write() argument must be string | 구글 앱 엔진

파이선으로 구글 앱 엔진 예제를 동작 시키던 중
위와 같은 에러가 생기면서 동작이 안되었다.

많은 내용들을 보니 유니코드로 바꾸면 된다는 결론
하지만 유니코드로 바꿀 때 안되는 부분이 있었다.
self.response.out.write(content.encode('utf-8'))
이 부분은 제대로 동작하지 않는듯 하다.
self.response.out.write(unicode(template.render('main.html', {})))
다시 찾다보니 위와 같이 바꾸니까 된다.

출처:
1. 동작안했던 유니코드 변환 부분
http://stackoverflow.com/questions/8558323/error-in-deployed-gae-requesthandler-using-webapp2
2. 동작하는 유니코드 변환부분
http://chrislee.kr/wp/tag/wsgirefhandlers-py-assertionerror-write-argument-must-be-string-python/