Ask Your Question
1

Askbot + Nginx + URL Accents = Problem

asked 2012-07-10 13:00:43 -0500

Erick Almeida gravatar image Erick Almeida
73 4 1 7

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.

delete close flag offensive retag edit

Comments

Anything interesting in the access/error logs?

Evgeny ( 2012-07-10 13:04:35 -0500 )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 ( 2012-07-12 13:13:05 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-07-12 13:11:33 -0500

Erick Almeida gravatar image Erick Almeida
73 4 1 7

updated 2012-07-12 13:13:39 -0500

Evgeny gravatar image Evgeny flag of Chile
11059 50 84 182
http://askbot.org/

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
link publish delete flag offensive edit

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 ( 2012-07-12 13:16:16 -0500 )edit

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

Erick Almeida ( 2012-07-12 13:29:14 -0500 )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 ( 2012-07-12 13:33:11 -0500 )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 ( 2012-07-12 15:32:20 -0500 )edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-07-10 13:00:43 -0500

Seen: 249 times

Last updated: Jul 12 '12