st4lk / django-solid-i18n-urls

[DEPRECATED] Use default language for urls without language prefix.
http://www.lexev.org/en/
Other
112 stars 29 forks source link

Not working with Gunicorn as expected #1

Closed margusholland closed 10 years ago

margusholland commented 10 years ago

Not really sure if it’s a case with this specific piece of code, but it seems to stop working correctly if I use it on Heroku and runnign Gunicorn.

I have Gunicorn running with multiple workers and if I use this code, the language preference starts to work randomly (I guess it depends which instance the request goes againts). It’s working correctly on the Django’s built-in server, but breaks on Gunicorn.

For example if I have EN as the default (non-prefixed url) and DE as the second language, everything is working fine if I just browse the / urls. Now, if I switch to /de/ (manually enter URL or switch from the Django language switcher), the main / url starts to work intermittently – if I keep refreshing the page, I get either a 404 or the page in DE. But there’s no way to switch it back to using EN completely again. Same happens with all the other URLs as well, I get either a 404 or the corresponding page in DE. And there’s no way to force it back to EN, even from the Django’s set_language view.

If I never touch the /de/ urls, it works all very wel without the prefixed URLs.

st4lk commented 10 years ago

Thanks for reporting! Please precise, what version of django and solid_urls are you using

margusholland commented 10 years ago

Django 1.6 and ot the latest yesterday from pip install.

st4lk commented 10 years ago

Currently can't reproduce the problem. I launch example project with gunicorn and 10 workers:

gunicorn -w 10 example.wsgi:application

All looks fine, both en and ru languages are rendered correctly (accessed 100 times the /ru/ page using 10 threads). Can you please try it with your project? Maybe on Heroku there is some additional environment, that cause the problem.

Here is my pip freeze output:

Django==1.6.2
solid-i18n==0.3.1
margusholland commented 10 years ago

Yes, you are 100% correct, works perfectly. Problem was actually in one of my own custom middleware classes. Sorry for the confusion and thanks for an awesome piece of code.