Hi,

as an alternative you can provide your own Storage implementation like
outlined here:

http://source.mihelac.org/2011/02/6/rename-uploaded-files-ascii-character-set-django/

Note: you may also need to override get_available_name to get it working
if i remember correctly.

hendrik


On 06/14/2012 05:38 PM, Paulo Almeida wrote:
> Hi,
> 
> Have you tried using SetEnv directives in .htaccess to change the
> locale? I'm not sure how that would interact with wsgi, but maybe
> something like this:
> 
> http://drumcoder.co.uk/blog/2010/nov/12/apache-environment-variables-and-mod_wsgi/
> 
> Of course you'd have to do it in .htaccess instead of Virtual Hosts.
> 
> Paulo
> 
> On Thursday, June 14, 2012 11:35:40 AM UTC+1, lawgon wrote:
> 
>     hi,
> 
>     I have an application which runs on a webfaction hosting. I also have
>     the same app running on my devel machine. The code in the two machines
>     are pulled from the same repo. Django versions are identical. Python
>     versions are identical. I try to upload a file called Lisäinfo
>     kummeille.pdf in the dev machine. No problem. When I try the same file
>     in webfaction, I get the above error. I have checked and find I can use
>     python to open and save a file of the same name from the python prompt
>     in the webfaction shell. In templates, admin and and generated pdfs,
>     these non ascii characters are handled perfectly. Has anyone got any
>     clues about this? The full traceback is given below:
> 
>     Environment:
> 
> 
>     Request Method: POST
>     Request URL: http://kenyakids.info/admin/web/download/add/
>     <http://kenyakids.info/admin/web/download/add/>
> 
>     Django Version: 1.4a1
>     Python Version: 2.7.3
>     Installed Applications:
>     ('django.contrib.auth',
>      'django.contrib.contenttypes',
>      'django.contrib.sessions',
>      'django.contrib.sites',
>      'django.contrib.admin',
>      'django.contrib.staticfiles',
>      'sorl.thumbnail',
>      'south',
>      'kenyakids.web',
>      'modeltranslation',
>      'rosetta')
>     Installed Middleware:
>     ('django.middleware.common.CommonMiddleware',
>      'django.contrib.sessions.middleware.SessionMiddleware',
>      'django.middleware.locale.LocaleMiddleware',
>      'django.contrib.auth.middleware.AuthenticationMiddleware',
>      'django.middleware.doc.XViewMiddleware',
>      'django.contrib.messages.middleware.MessageMiddleware')
> 
> 
>     Traceback:
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/handlers/base.py"
>     in get_response
>       111.                         response = callback(request,
>     *callback_args, **callback_kwargs)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/contrib/admin/options.py"
>     in wrapper
>       367.                 return self.admin_site.admin_view(view)(*args,
>     **kwargs)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/utils/decorators.py"
>     in _wrapped_view
>       91.                     response = view_func(request, *args,
>     **kwargs)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/views/decorators/cache.py"
>     in _wrapped_view_func
>       88.         response = view_func(request, *args, **kwargs)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/contrib/admin/sites.py"
>     in inner
>       192.             return view(request, *args, **kwargs)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/utils/decorators.py"
>     in _wrapper
>       25.             return bound_func(*args, **kwargs)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/utils/decorators.py"
>     in _wrapped_view
>       91.                     response = view_func(request, *args,
>     **kwargs)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/utils/decorators.py"
>     in bound_func
>       21.                 return func(self, *args2, **kwargs2)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/db/transaction.py"
>     in inner
>       209.                 return func(*args, **kwargs)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/contrib/admin/options.py"
>     in add_view
>       955.                 self.save_model(request, new_object, form,
>     False)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/contrib/admin/options.py"
>     in save_model
>       709.         obj.save()
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/base.py"
>     in save
>       464.         self.save_base(using=using, force_insert=force_insert,
>     force_update=force_update)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/base.py"
>     in save_base
>       552.                 result = manager._insert([self], fields=fields,
>     return_id=update_pk, using=using, raw=raw)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/manager.py"
>     in _insert
>       203.         return insert_query(self.model, objs, fields, **kwargs)
>     File
>     "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/query.py"
> 
>     in insert_query
>       1576.     return
>     query.get_compiler(using=using).execute_sql(return_id)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/sql/compiler.py"
>     in execute_sql
>       909.         for sql, params in self.as_sql():
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/sql/compiler.py"
>     in as_sql
>       872.                 for obj in self.query.objs
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/fields/files.py"
>     in pre_save
>       249.             file.save(file.name <http://file.name>, file,
>     save=False)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/db/models/fields/files.py"
>     in save
>       86.         self.name <http://self.name> = self.storage.save(name,
>     content)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py"
>     in save
>       44.         name = self.get_available_name(name)
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py"
>     in get_available_name
>       70.         while self.exists(name):
>     File
>     
> "/home/kenyakids/webapps/django/lib/python2.7/django/core/files/storage.py"
>     in exists
>       230.         return os.path.exists(self.path(name))
>     File "/usr/local/lib/python2.7/genericpath.py" in exists
>       18.         os.stat(path)
> 
>     Exception Type: UnicodeEncodeError at /admin/web/download/add/
>     Exception Value: 'ascii' codec can't encode character u'\xe4' in
>     position 71: ordinal not in range(128)
> 
> 
>     -- 
>     regards
>     Kenneth Gonsalves
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/3B3Y--yCilsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to