Ticket #13550: non_ascii_chars_fix.diff

File non_ascii_chars_fix.diff, 1.8 KB (added by oyvind, 14 years ago)

Fix, but probably not the right way

  • django/core/files/storage.py

     
    134134        self.base_url = base_url
    135135
    136136    def _open(self, name, mode='rb'):
    137         return File(open(self.path(name), mode))
     137        return File(open(self.path_str(name), mode))
    138138
    139139    def _save(self, name, content):
    140         full_path = self.path(name)
     140        full_path = self.path_str(name)
    141141
    142142        directory = os.path.dirname(full_path)
    143143        if not os.path.exists(directory):
     
    174174                if e.errno == errno.EEXIST:
    175175                    # Ooops, the file exists. We need a new file name.
    176176                    name = self.get_available_name(name)
    177                     full_path = self.path(name)
     177                    full_path = self.path_str(name)
    178178                else:
    179179                    raise
    180180            else:
     
    187187        return name
    188188
    189189    def delete(self, name):
    190         name = self.path(name)
     190        name = self.path_str(name)
    191191        # If the file exists, delete it from the filesystem.
    192192        if os.path.exists(name):
    193193            os.remove(name)
    194194
    195195    def exists(self, name):
    196         return os.path.exists(self.path(name))
     196        return os.path.exists(self.path_str(name))
    197197
    198198    def listdir(self, path):
    199199        path = self.path(path)
     
    211211        except ValueError:
    212212            raise SuspiciousOperation("Attempted access to '%s' denied." % name)
    213213        return os.path.normpath(path)
     214   
     215    def path_str(self, name):
     216        return self.path(name).encode('utf-8')
    214217
    215218    def size(self, name):
    216         return os.path.getsize(self.path(name))
     219        return os.path.getsize(self.path_str(name))
    217220
    218221    def url(self, name):
    219222        if self.base_url is None:
Back to Top