commit 01e9383d368298a1962aaab4f10d374d8549eb98
parent 141a3e1c95559ba5cb9de7dc8e1ef1f02103d14f
Author: Dan Callaghan <djc@djc.id.au>
Date: Wed, 19 Nov 2008 20:06:47 +1000
avoid unicode paths entirely, since os.listdir's unicode support appears to be quite broken
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/app.py b/app.py
@@ -74,8 +74,8 @@ class Constance(object):
v.decode(self.encoding, 'ignore'))
for k, v in cgi.parse_qsl(self.post_data, True))
- self.blog_entries = blog.BlogEntrySet(self.config.getunicode('blog', 'dir'))
- readinglog_filename = self.config.getunicode('readinglog', 'filename')
+ self.blog_entries = blog.BlogEntrySet(self.config.get('blog', 'dir'))
+ readinglog_filename = self.config.get('readinglog', 'filename')
if readinglog_filename:
self.readinglog_entries = blog.ReadingLogEntrySet(readinglog_filename)
else:
diff --git a/blog.py b/blog.py
@@ -60,6 +60,7 @@ class DirectoryEntrySet(object):
if not filename.startswith('.'))
def __iter__(self):
+ assert isinstance(self.base_dir, str)
return (self.entry_class(self.base_dir, filename)
for filename in os.listdir(self.base_dir)
if not filename.startswith('.'))
@@ -79,8 +80,8 @@ class YamlEntrySet(object):
class BlogEntry(object):
def __init__(self, entries_dir, id):
- assert isinstance(id, unicode), id
- self.id = id
+ assert isinstance(id, str), id
+ self.id = id.decode('utf8') # XXX shouldn't hardcode the encoding
self.dir = os.path.join(entries_dir, id)
self.comments_dir = os.path.join(self.dir, 'comments')