First time here? Check out the FAQ!
1

Askbot + Nginx + URL Accents = Problem

I install Askbot with Nginx and configure pt_BR locale. All URL with accent broken. After this I install apache(slow) and everything works fine.

Erick Almeida's avatar
73
Erick Almeida
asked 2012-07-10 13:00:43 -0600
edit flag offensive 0 remove flag close merge delete

Comments

Anything interesting in the access/error logs?

Evgeny's avatar Evgeny (2012-07-10 13:04:35 -0600) edit

Erick, you can use 'shift-enter' to add new lines in the comments and code can be formatted with markdown - indent lines by 4 chars and precede by one empty. For a long log - just paste into the question body.

Evgeny's avatar Evgeny (2012-07-12 13:13:05 -0600) edit
add a comment see more comments

1 Answer

0

I post the log here because the comments don't allow size.

Yes there is a log:

2012/07/10 11:36:05 [error] 3863#0: *12 FastCGI sent in stderr: "Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/flup/server/fcgi_base.py", line 558, in run
    protocolStatus, appStatus = self.server.handler(self)
  File "/usr/lib/pymodules/python2.7/flup/server/fcgi_base.py", line 1118, in handler
    result = self.application(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 146, in get_response
    response = debug.technical_404_response(request, e)
  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 294, in technical_404_response
    'reason': smart_str(exception, errors='replace'),
  File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 123, in smart_str
    errors) for arg in s])
  File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 124, in smart_str
    return unicode(s).encode(encoding, errors)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 27: ordinal not in range(128)" while reading response header from upstream, client: 10.0.0.10, server: ask.alterdata.matriz
Erick Almeida's avatar
73
Erick Almeida
answered 2012-07-12 13:11:33 -0600
Evgeny's avatar
13.2k
Evgeny
updated 2012-07-12 13:13:39 -0600
edit flag offensive 0 remove flag delete link

Comments

Ok, next time please edit the question instead. I think the default encoding in python is wrong - the value of 'encoding' is probably ascii and it's indeed impossible to encode those chars into one-byte codes.

Evgeny's avatar Evgeny (2012-07-12 13:16:16 -0600) edit

Why works when I change from Nginx to Apache2? If I run the development server (runserver) works too.

Erick Almeida's avatar Erick Almeida (2012-07-12 13:29:14 -0600) edit

Probably b/c of the differences in how python interpreter was started, possibly due to compilation opions in the webserver. Remember that in apache you're probably using mod_wsgi, for nginx - gunicorn, uwsgi or something like that. Look at what actually runs python in your setup. You can use a trick in the .wsgi script sys.stderr.write(...whichever variable you want to test) to debug. Test what is default encoding in django in those cases. There is some documentation on django site about it.

Evgeny's avatar Evgeny (2012-07-12 13:33:11 -0600) edit

On the subject of default encoding - take a look here: http://blog.ianbicking.org/illusive-setdefaultencoding.html I've tested on two systems and on one (my mac laptop - I don't have this issue, and another - ubuntu server - I have the issue). It is definitely in the python setup of default character encoding.

Evgeny's avatar Evgeny (2012-07-12 15:32:20 -0600) edit
add a comment see more comments