From f0fb6cfbcba9573f738c6d438db42c2b847bbdf5 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 20 Jul 2010 15:55:54 -0400 Subject: [PATCH] Adjustment so that web.py works with unicode paths --- dirtag/__init__.py | 1 - dirtag/web.py | 69 ++++++++++++++++++++++++++++++---------------- test/raw/b/b1.svg | 3 +- 3 files changed, 47 insertions(+), 26 deletions(-) diff --git a/dirtag/__init__.py b/dirtag/__init__.py index f55b88f..175665c 100644 --- a/dirtag/__init__.py +++ b/dirtag/__init__.py @@ -357,7 +357,6 @@ class Dirtag (object): if __name__ == '__main__': # Uncomment the following lines if you're having problems with # UTF-8 in your docstrings. - #import sys #reload(sys) #sys.setdefaultencoding('utf-8') diff --git a/dirtag/web.py b/dirtag/web.py index abbbcfd..0bee179 100755 --- a/dirtag/web.py +++ b/dirtag/web.py @@ -4,7 +4,7 @@ from mimetypes import guess_type from optparse import OptionParser import os from os import path -from urllib import urlencode +from urllib import urlencode, quote_plus import cherrypy from jinja2 import Environment, FileSystemLoader @@ -23,6 +23,9 @@ class WebInterface: self.repository_name = repository_name self.rdf_root = 'http://dirtag.com/' + def _url(self, url): + return unicode(quote_plus(url.encode('utf-8')), 'utf-8') + # RESTful HTML interface @cherrypy.expose @@ -36,18 +39,27 @@ class WebInterface: def _dir_html(self, root_dir): """ - >>> x = WebInterface(None) - >>> print x._dir_html('test/tag') + >>> d = Dirtag(raw_dir=u'test/raw', tag_dir=u'test/tag') + >>> x = WebInterface(d) + >>> print x._dir_html(d.tag_dir) + >>> for line in x._dir_html(d.raw_dir).split('\\n'): + ... print repr(line) + u'' """ lines = ['