---
title: "更正一个GAE SDK的bug"
author: "john2007"
date: "2010-01-20T15:03:48Z"
tags: []
categories: ["编程语言"]
slug: "gae-sdk-bug"
draft: false
lastmod: "2010-01-20T15:07:18Z"
id: 575642
url: "https://john2007.iteye.com/blog/575642"
---

当我们在gae的数据存储中存储了数据后，可以利用SDK提供的 sdk console （[http://localhost:8081/\_ah/admin/datastore](http://localhost:8081/_ah/admin/datastore)）方便的进行数据的浏览和修改。

 

但是如果字段中有中文数据记录，就会出错。一个stack就猜到是中文编码的问题。（部署在服务器上好像没有此现象。）

具体更正方法就是对字符进行正确的编码。

 

1、所有的py文件用utf8编码；

 

2、对

D:\\Program Files\\G-o-o-g-l-e\\g-o-o-g-l-e\_appengine\\g-o-o-g-l-e\\appengine\\ext\\admin\\\_\_init\_\_.py 的修改：主要是三处字符串变量的编码和解码。

 line 926: cgi.escape(string\_value.decode("utf8"), True))

 

line 940:value = str(value.encode("utf8") )

 

line 941:sample\_values = \[str(s.encode("utf8")) for s in sample\_values]

附：修改后的文件见附件。