Navigation Menu

Skip to content

Commit

Permalink
Attempt to fix UnicodeDecodeError.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jan 19, 2011
1 parent 29c30d4 commit 615896d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tracstats/web_ui.py
Expand Up @@ -13,7 +13,7 @@
from trac.core import *
from trac.mimeview import Mimeview
from trac.perm import IPermissionRequestor
from trac.util import get_reporter_id
from trac.util import get_reporter_id, to_unicode
from trac.util.datefmt import pretty_timedelta, to_datetime
from trac.util.html import html, Markup
from trac.web import IRequestHandler
Expand Down Expand Up @@ -145,30 +145,36 @@ def process_request(self, req):
data['title'] = 'Stats'
result = self._process(req, cursor, where, data)
cursor.close()
return result

elif path == '/code':
data['title'] = 'Code' + (author and (' (%s)' % author))
result = self._process_code(req, cursor, where, data)
cursor.close()
return result

elif path == '/wiki':
data['title'] = 'Wiki ' + (author and (' (%s)' % author))
result = self._process_wiki(req, cursor, where, data)
cursor.close()
return result

elif path == '/tickets':
data['title'] = 'Tickets' + (author and (' (%s)' % author))
result = self._process_tickets(req, cursor, where, data)
cursor.close()
return result

else:
cursor.close()
raise ValueError, "unknown path '%s'" % path

# Clean the unicode values for Genshi
template_name, data, content_type = result
new_data = {}
for k, v in data.iteritems():
if isinstance(v, str):
new_data[k] = to_unicode(v)
else:
new_data[k] = v
return template_name, new_data, content_type


def _process(self, req, cursor, where, data):

Expand Down

0 comments on commit 615896d

Please sign in to comment.