List Info

Thread: What is the right order of LocaleMiddleware and CacheMiddleware?




What is the right order of LocaleMiddleware and CacheMiddleware?
user name
2006-03-31 20:24:17
I have build a website in three languages and I want to use
caching. I
have read the documentation thouroughly. I also read the
source code
repository and the django newsgroups.

I am very confused about the order in which to put all the
Middleware
classes.

Does anybody know what the right order should be of the
following 4
middleware classes?

MIDDLEWARE_CLASSES = (
	"django.middleware.sessions.SessionMiddleware",
	"django.middleware.cache.CacheMiddleware",
	"django.middleware.locale.LocaleMiddleware",
	"django.middleware.common.CommonMiddleware",
)

Until now every order I tried does not work. When you switch
to another
language, the switch does not work or while browsing the
site you will
end up with pages in the wrong language.

As soon as I switch of the CacheMiddleware everything works
perfectly.

Thanks,

Berry


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

What is the right order of LocaleMiddleware and CacheMiddleware?
user name
2006-03-31 21:33:56
Beegee wrote:
> I have build a website in three languages and I want to
use caching. I
> have read the documentation thouroughly. I also read
the source code
> repository and the django newsgroups.
> 
> I am very confused about the order in which to put all
the Middleware
> classes.
> 
> Does anybody know what the right order should be of the
following 4
> middleware classes?
> 
> MIDDLEWARE_CLASSES = (
>
	"django.middleware.sessions.SessionMiddleware",
> 	"django.middleware.cache.CacheMiddleware",
>
	"django.middleware.locale.LocaleMiddleware",
>
	"django.middleware.common.CommonMiddleware",
> )
> 
> Until now every order I tried does not work. When you
switch to another
> language, the switch does not work or while browsing
the site you will
> end up with pages in the wrong language.
> 
> As soon as I switch of the CacheMiddleware everything
works perfectly.

Fromhttp
://www.djangoproject.com/documentation/i18n/ :

	It should come after SessionMiddleware, because
LocaleMiddleware makes use of session data.
	If you use CacheMiddleware, put LocaleMiddleware after it.

so (untested):

MIDDLEWARE_CLASSES = (
   'django.middleware.sessions.SessionMiddleware',
   'django.middleware.locale.LocaleMiddleware',
   'django.middleware.cache.CacheMiddleware',
   'django.middleware.common.CommonMiddleware',
)

But I'm not sure that works, I tried this a long time ago
with no success (before
http://www.djangoproject.c
om/documentation/cache/#controlling-cache-using-vary-headers
 are introduced).

If you (or anyone) have solution, be sure to post here, I'm
listening 

-- 
Nebojša Đorđević - nesh
Studio Quattro - Niš - SCG
http://studioquattro.biz/
http://djnesh.blogspot.co
m/  |  http://djnesh-djan
go.blogspot.com/ |  http://djangou
tils.python-hosting.com/
Registered Linux User 282159 [http://counter.li.org]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )