[bfss] convert root BFSS directory to str in constructor (closes #2137793) stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Tue, 03 Jan 2012 17:00:43 +0100
branchstable
changeset 8148 b7a195d54fd4
parent 8147 335b358c7017
child 8149 3ed48646f354
[bfss] convert root BFSS directory to str in constructor (closes #2137793) otherwise you can get crashed with AssertionError: Binary objects must use raw strings, not <type 'unicode'>
server/sources/storages.py
--- a/server/sources/storages.py	Tue Jan 03 12:21:44 2012 +0100
+++ b/server/sources/storages.py	Tue Jan 03 17:00:43 2012 +0100
@@ -113,6 +113,8 @@
 class BytesFileSystemStorage(Storage):
     """store Bytes attribute value on the file system"""
     def __init__(self, defaultdir, fsencoding='utf-8'):
+        if type(defaultdir) is unicode:
+            defaultdir = defaultdir.encode(fsencoding)
         self.default_directory = defaultdir
         self.fsencoding = fsencoding
 
@@ -201,7 +203,8 @@
         name = entity.cw_attr_metadata(attr, 'name')
         if name is not None:
             basename.append(name.encode(self.fsencoding))
-        fspath = uniquify_path(self.default_directory, '_'.join(basename))
+        fspath = uniquify_path(self.default_directory,
+                               '_'.join(basename))
         if fspath is None:
             msg = entity._cw._('failed to uniquify path (%s, %s)') % (
                 self.default_directory, '_'.join(basename))