[Patch] Vote counter problem in trac 0.12
|Reported by:||Peter||Owned by:||Ryan J Ollos|
I'm getting an issue with this plugin with trac 0.12. After installing this plugin it does not update the vote counter when clicked on, in my installation. However when I reload the page the vote counter is incremented. When investigating my trac log I found it was generating the following error.
File "build\bdist.win32\egg\tracvote\__init__.py", line 152, in process_request body, title))) File "c:\docume~1\lp03\locals~1\temp\1\easy_install-kpxh76\Trac-0.12-py2.7-win32.egg.tmp\trac\web\api.py", line 412, in send self.write(content) File "c:\docume~1\lp03\locals~1\temp\1\easy_install-kpxh76\Trac-0.12-py2.7-win32.egg.tmp\trac\web\api.py", line 530, in write raise ValueError("Can't send unicode content") ValueError: Can't send unicode content
On further investigation I think this is related to an API change in 0.12 to refuse taking unicode see http://trac.edgewall.org/ticket/8675
To fix it, for now, I've changed the function process_request, in the
__init__.py file along similar lines as suggested in the above link. i.e. I convert the string passed to req.send to utf-8 if in an unicode format. See new process_request function below...
def process_request(self, req): req.perm.require('VOTE_MODIFY') match = self.path_match.match(req.path_info) vote, resource = match.groups() resource = self.normalise_resource(resource) vote = vote == 'up' and +1 or -1 old_vote = self.get_vote(req, resource) if old_vote == vote: vote = 0 self.set_vote(req, resource, 0) else: self.set_vote(req, resource, vote) if req.args.get('js'): body, title = self.format_votes(resource) content = ':'.join((req.href.chrome('vote/' + self.image_map[vote]), req.href.chrome('vote/' + self.image_map[vote]), body, title)); if isinstance(content, unicode): content = content.encode('utf-8') req.send(content); req.redirect(resource)
Change History (7)
comment:1 Changed 7 years ago by
|Summary:||vote counter problem in trac 0.12 (uni → [Patch] Vote counter problem in trac 0.12|