English 中文(简体)
D. lin格案卷Browser 3.2 气球中的下降
原标题:Decoding error in django filebrowser 3.2 on linux

The error message:

Traceback:
File "/web/hvita_perlan/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/web/hvita_perlan/lib/python2.6/site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  19.             return view_func(request, *args, **kwargs)
File "/web/hvita_perlan/lib/python2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "/web/hvita_perlan/lib/python2.6/site-packages/filebrowser/views.py" in browse
  99.         fileobject = FileObject(os.path.join(file_dir, file))
File "/web/hvita_perlan/lib/python2.6/posixpath.py" in join
  70.             path +=  /  + b

Exception Type: UnicodeDecodeError at /admin/filebrowser/browse/
Exception Value:  ascii  codec can t decode byte 0xc3 in position 3: ordinal not in range(128)

无法编码/编码的示意图是: 1h .j

文档名称为:1hæð.jpg

some info:

> locale
LANG=en_GB.UTF-8

-

> python manage.py shell
>>> import locale
>>> locale.getlocale()
( en_GB ,  UTF8 )

>>> import os
>>> os.stat( ../uploads/_promotional/1hæð_fb_thumb.jpg )
posix.stat_result(st_mode=33279, st_ino=788504L, st_dev=51713L, st_nlink=1, st_uid=0, st_gid=0, st_size=1629L, st_atime=1311176542, st_mtime=1311176542, st_ctime=1311177235)

你们可以看一看一切事事事,但不是在 d戈案卷本。

最佳回答
问题回答

参看:。 文件只支持ASCII

它是例外:

<代码>Exception 价值:cii 代码c 可在3级而不是范围(128)的0xc3级编码上打字。

os.path.join(file_dir, file) 正在获得一个统法协会的编码,并且被隐含地编码到ASCII,而不是UTF-8。 为了消除这一问题,在Adhur3中进行了单条编码/直线改动。

在一些地方,file_dir需要与file_dir.encode(utf-8 )编码。 作为使之发挥作用的坏 ha,你可以在第99条线上尝试在<条码>/web/hvita_perlan/lib/python2.6/site- Pack/filebrowser/views.py上这样做:

fileobject = FileObject(os.path.join(file_dir.encode( utf-8 ), file))

然后测试,每当你发现一个新地点引发这一错误时,就重复。

In django-filebrowser 3.5.6 there is a setting FILEBROWSER_NORMALIZE_FILENAME if set to true in your settings.py it will make fb strip non standard characters from the file name. I had trouble finding info about it so posting it here enven though not sure if it works for the older version.

Its an old post but the issue remains.
I m using django, apache2, django-filebrowser and get this Exception Value: ascii codec can t decode byte 0xc3 in position...

对我来说,哪怕是使用 mo子。

#https://docs.djangoproject.com/en/1.2/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror
#Put this in your apache2/envvars file.

export LANG= en_US.UTF-8 
export LC_ALL= en_US.UTF-8 

Hope it helps someone.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...