From a3bc7681b54d62a6b54f3b05b05b91e9304c26eb Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 28 Aug 2011 22:23:44 -0400 Subject: [PATCH] godashboard: fix utf-8 in user names Also standardize on 'utf8' as encoding name. Apparently either is acceptable. The user, because it is a StringProperty, must be of type unicode in order to handle Unicode correctly. It must *not* have type string. The desc, because it is a BlobProperty, must be of type string in order to handle Unicode correctly. It must *not* have type unicode. Yay encoding type pedantry without static typing. R=adg, mattn.jp CC=golang-dev https://golang.org/cl/4973045 --- misc/dashboard/godashboard/app.yaml | 2 +- misc/dashboard/godashboard/gobuild.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/misc/dashboard/godashboard/app.yaml b/misc/dashboard/godashboard/app.yaml index 7b77a85ccc..215c163306 100644 --- a/misc/dashboard/godashboard/app.yaml +++ b/misc/dashboard/godashboard/app.yaml @@ -1,5 +1,5 @@ application: godashboard -version: 7 +version: 8 runtime: python api_version: 1 diff --git a/misc/dashboard/godashboard/gobuild.py b/misc/dashboard/godashboard/gobuild.py index 685dc83a9b..7ccbdebb65 100644 --- a/misc/dashboard/godashboard/gobuild.py +++ b/misc/dashboard/godashboard/gobuild.py @@ -32,6 +32,9 @@ import const # numbers in an hg repo. When inserting a new commit, the parent commit must be # given and this is used to generate the new commit number. In order to create # the first Commit object, a special command (/init) is used. +# +# N.B. user is a StringProperty, so it must be type 'unicode'. +# desc is a BlobProperty, so it must be type 'string'. [sic] class Commit(db.Model): num = db.IntegerProperty() # internal, monotonic counter. node = db.StringProperty() # Hg hash @@ -199,7 +202,7 @@ class Init(DashboardHandler): commit.num = 0 commit.node = node commit.parentnode = '' - commit.user = self.request.get('user').encode('utf8') + commit.user = self.request.get('user') commit.date = date commit.desc = self.request.get('desc').encode('utf8') @@ -233,7 +236,7 @@ class CommitHandler(DashboardHandler): node = self.request.get('node') date = parseDate(self.request.get('date')) - user = self.request.get('user').encode('utf8') + user = self.request.get('user') desc = self.request.get('desc').encode('utf8') parenthash = self.request.get('parent') @@ -276,7 +279,7 @@ class CommitHandler(DashboardHandler): n.parentnode = parenthash n.user = user n.date = date - n.desc = desc + n.desc = desc.encode('utf8') n.put() db.run_in_transaction(add_commit) n = nodeByHash(node) @@ -294,7 +297,7 @@ class Build(webapp.RequestHandler): return builder = self.request.get('builder') - log = self.request.get('log').encode('utf-8') + log = self.request.get('log').encode('utf8') loghash = '' if len(log) > 0: -- 2.50.0