Re: Caching and I18n

2008-11-25 Thread Antoni Aloy

2008/11/25 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Hello Aloy,
>
> I saw the great work you did on ticket #5691. Thanks a lot, I highly
> appreciate that! We have to offer our first release with the bug, but
> I hope to be able to include your patch or a workaround for the next
> one and will give feedback once that's been done.
>
It's nice to help!

But you have to consider this is my first patch on Django core, and I
just be really sure that everything is ok when one of django main
developers double check the tests :)

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-25 Thread [EMAIL PROTECTED]

Hello Aloy,

I saw the great work you did on ticket #5691. Thanks a lot, I highly
appreciate that! We have to offer our first release with the bug, but
I hope to be able to include your patch or a workaround for the next
one and will give feedback once that's been done.

With regards,
Maik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-20 Thread Antoni Aloy

2008/11/20 Malcolm Tredinnick <[EMAIL PROTECTED]>:
>

>
> Andrew's final comment on that ticket is accurate. Removing the code
> duplication is pretty easy there and following the examples in
> tests/regressiontests/middleware/tests.py to create some tests for it
> should be fairly straightforward as well. So it looks close.
>
> Regards,
> Malcolm

Anybody on this thread is going to take the ticket? I could take a
look at it and make the tests.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-20 Thread Malcolm Tredinnick


On Thu, 2008-11-20 at 07:17 -0200, Ramiro Morales wrote:
> On Sun, Nov 16, 2008 at 10:14 PM, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
> >
> > Hello Ramiro,
> >
> > thanks for your reply. According to the docs, the Locale and Session
> > middlewares should set the Vary-On headers accordingly, and indeed
> > they are:
> >
> > Date: Sun, 16 Nov 2008 23:49:29 GMT
> > Server: WSGIServer/0.1 Python/2.5.2
> > Vary: Accept-Language, Cookie
> > Content-Type: text/html; charset=utf-8
> > Content-Language: de
> >
> > 200 OK
> >
> > I'm lost. Maybe Beegee from the other thread found a solution in the
> > meantime.
> 
> I asked Antoni Aloy that was the OP in one of these threads.
> He pointed me to [1]ticket 5691 he opened back then. You might want to take
> a look at it (to know propossed solutions, code devs opinions and
> perhaps to post feedback and enhance the patch si it can be applied?).

That ticket was mostly just waiting until we sorted out the whole
problem with cache middleware ordering with respect to almost everything
else (especially sessions). That's ticket #730 that is referred to
there. We fixed that properly in time for 1.0, so that ticket can now
move ahead.

Andrew's final comment on that ticket is accurate. Removing the code
duplication is pretty easy there and following the examples in
tests/regressiontests/middleware/tests.py to create some tests for it
should be fairly straightforward as well. So it looks close.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-20 Thread Ramiro Morales

On Sun, Nov 16, 2008 at 10:14 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hello Ramiro,
>
> thanks for your reply. According to the docs, the Locale and Session
> middlewares should set the Vary-On headers accordingly, and indeed
> they are:
>
> Date: Sun, 16 Nov 2008 23:49:29 GMT
> Server: WSGIServer/0.1 Python/2.5.2
> Vary: Accept-Language, Cookie
> Content-Type: text/html; charset=utf-8
> Content-Language: de
>
> 200 OK
>
> I'm lost. Maybe Beegee from the other thread found a solution in the
> meantime.

I asked Antoni Aloy that was the OP in one of these threads.
He pointed me to [1]ticket 5691 he opened back then. You might want to take
a look at it (to know propossed solutions, code devs opinions and
perhaps to post feedback and enhance the patch si it can be applied?).

HTH

-- 
 Ramiro Morales

1. http://code.djangoproject.com/ticket/5691

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-16 Thread [EMAIL PROTECTED]

Hello Ramiro,

thanks for your reply. According to the docs, the Locale and Session
middlewares should set the Vary-On headers accordingly, and indeed
they are:

Date: Sun, 16 Nov 2008 23:49:29 GMT
Server: WSGIServer/0.1 Python/2.5.2
Vary: Accept-Language, Cookie
Content-Type: text/html; charset=utf-8
Content-Language: de

200 OK

I'm lost. Maybe Beegee from the other thread found a solution in the
meantime.

On Nov 16, 10:33 pm, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On Sun, Nov 16, 2008 at 10:51 AM, [EMAIL PROTECTED]
>
>
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > Hello everyone,
>
> > I'm trying to implement caching for my bilingual site. The problem is
> > that once I enable caching and I change the language (via the example
> > code 
> > inhttp://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-se...
> > ), the page does not change. The Content-Language header that the
> > browser receives is indeed changed accordingly, but apparently the
> > caching system is not aware of the change.
> > I've set up my middleware as follows:
>
> > MIDDLEWARE_CLASSES = (
> >    'django.middleware.cache.UpdateCacheMiddleware',
> >    'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
> > auth
> >    'django.contrib.auth.middleware.AuthenticationMiddleware',
> >    'django.middleware.locale.LocaleMiddleware',
> >    'django.middleware.common.CommonMiddleware',
> >    'django.middleware.cache.FetchFromCacheMiddleware',
> > )
>
> > I also tried per-site caching (disabling caching in the middleware),
> > but did get the same results, even when I specified vary_on_headers
> > ('Content-Language','Accept-Language').
>
> > I have found a snippet (http://www.djangosnippets.org/snippets/443/)
> > that might work, but I'm reluctant to use this hack and also rely on
> > the deprecated CacheMiddleware.
>
> > Any help and hints are appreciated!
>
> > Thanks,
> > Maik
>
> > PS. relevant settings.py excerpt:
> > CACHE_BACKEND = 'locmem:///'
> > CACHE_MIDDLEWARE_SECONDS = 300
> > CACHE_MIDDLEWARE_KEY_PREFIX = ''
> > CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
>
> The user's language preference might end being stored (and sent back) in
> the django language preferences cookie or the session-related cookie.
> So, to cover all the possible channels that preference could come in,
> you will also need to indicate 'cookie', in the Vary header:
>
> @vary_on_headers(''Accept-Language', 'Cookie')
>
> See the following posts for related discussions:
>
> http://groups.google.com/group/django-developers/browse_thread/thread...http://groups.google.com/group/django-users/browse_thread/thread/256f...
>
> Regards,
>
> --
>  Ramiro Morales
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-16 Thread Ramiro Morales

On Sun, Nov 16, 2008 at 10:51 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hello everyone,
>
> I'm trying to implement caching for my bilingual site. The problem is
> that once I enable caching and I change the language (via the example
> code in 
> http://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-set-language-redirect-view
> ), the page does not change. The Content-Language header that the
> browser receives is indeed changed accordingly, but apparently the
> caching system is not aware of the change.
> I've set up my middleware as follows:
>
> MIDDLEWARE_CLASSES = (
>'django.middleware.cache.UpdateCacheMiddleware',
>'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
> auth
>'django.contrib.auth.middleware.AuthenticationMiddleware',
>'django.middleware.locale.LocaleMiddleware',
>'django.middleware.common.CommonMiddleware',
>'django.middleware.cache.FetchFromCacheMiddleware',
> )
>
> I also tried per-site caching (disabling caching in the middleware),
> but did get the same results, even when I specified vary_on_headers
> ('Content-Language','Accept-Language').
>
> I have found a snippet (http://www.djangosnippets.org/snippets/443/)
> that might work, but I'm reluctant to use this hack and also rely on
> the deprecated CacheMiddleware.
>
> Any help and hints are appreciated!
>
> Thanks,
> Maik
>
> PS. relevant settings.py excerpt:
> CACHE_BACKEND = 'locmem:///'
> CACHE_MIDDLEWARE_SECONDS = 300
> CACHE_MIDDLEWARE_KEY_PREFIX = ''
> CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
>

The user's language preference might end being stored (and sent back) in
the django language preferences cookie or the session-related cookie.
So, to cover all the possible channels that preference could come in,
you will also need to indicate 'cookie', in the Vary header:

@vary_on_headers(''Accept-Language', 'Cookie')

See the following posts for related discussions:

http://groups.google.com/group/django-developers/browse_thread/thread/740f8d434e0660ff/5033945a4cdde102?hl=en=gst
http://groups.google.com/group/django-users/browse_thread/thread/256faa01c62b4f27/f4a382c540f47b5b?hl=en=gst

Regards,

--
 Ramiro Morales

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Caching and I18n

2008-11-16 Thread [EMAIL PROTECTED]

Hello everyone,

I'm trying to implement caching for my bilingual site. The problem is
that once I enable caching and I change the language (via the example
code in 
http://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-set-language-redirect-view
), the page does not change. The Content-Language header that the
browser receives is indeed changed accordingly, but apparently the
caching system is not aware of the change.
I've set up my middleware as follows:

MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
auth
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)

I also tried per-site caching (disabling caching in the middleware),
but did get the same results, even when I specified vary_on_headers
('Content-Language','Accept-Language').

I have found a snippet (http://www.djangosnippets.org/snippets/443/)
that might work, but I'm reluctant to use this hack and also rely on
the deprecated CacheMiddleware.

Any help and hints are appreciated!

Thanks,
Maik

PS. relevant settings.py excerpt:
CACHE_BACKEND = 'locmem:///'
CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---