Issue #12 resolved
Gilles Bassière
created an issue

When the file_name member of ShpResponder is assigned an unicode string, the zip.write method fails.

I guess it has to do with and it may be considered as a limitation rather than a bug.

I haven't been able to find a generic solution to this problem. My workaround was merely to cast my unicode as str but this won't work in every cases.



Comments (5)

  1. Dane Springmeyer repo owner

    Does this work for you?

    ^Cspringmeyer:django-shapes spring$ hg diff shapes
    diff -r 7ffecf949308 shapes/views/
    --- a/shapes/views/    Thu Oct 01 09:24:28 2009 -0700
    +++ b/shapes/views/    Tue Oct 20 17:41:37 2009 -0700
    @@ -19,7 +19,10 @@
             self.geo_field = geo_field
             self.proj_transform = proj_transform
             self.mimetype = mimetype
    -        self.file_name = file_name
    +        try:
    +            self.file_name = file_name.encode('ascii')
    +        except UnicodeEncodeError:
    +            self.file_name = file_name.encode('utf-8')
         def __call__(self, *args, **kwargs):
  2. Gilles Bassière reporter

    That works fine for me. Thanks for your quick reply.

    In the meantime, I found another option which is to use Django's smart_str function:

    from django.utils.encoding import smart_str
    self.file_name = smart_str(file_name)
  3. Log in to comment