Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-27 Thread Alexis Bellido
I just created a ticket reporting this issue as a bug: https://code.djangoproject.com/ticket/18863 Thanks for all the suggestions. On Tuesday, August 21, 2012 2:27:04 PM UTC-3, Alexis Bellido wrote: > > Hello, > > I am working on a Django 1.4 project and writing one simple application > using p

Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-24 Thread Bill Freeman
While u = request.user may not be enough, request.user.username should be (I don't think you even have to put it in a variable, python will evaluate it even if the result is discarded). On Thu, Aug 23, 2012 at 9:20 AM, Alexis Bellido wrote: > Ok, I just confirmed my "problem" was caused by Dj

Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-24 Thread Melvyn Sopacua
On 23-8-2012 15:20, Alexis Bellido wrote: > And I got an error message telling me I couldn't concatenate an str to a > SimpleLazyObject. At this point the lazy loading logic hasn't got a real > User object yet. > > To bypass the lazy loading, hence return a non-cache view for authenticated > u

Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-23 Thread Alexis Bellido
Ok, I just confirmed my "problem" was caused by Django lazy loading the User object. To confirm it, I just added something like this to my view: test_var = "some text" + request.user And I got an error message telling me I couldn't concatenate an str to a SimpleLazyObject. At this point the la

Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-23 Thread Alexis Bellido
Hi, Yeah, the optimization approach makes sense but it's misleading as the settings says CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True, which makes you think that every view that is requested by an authenticated user is non-cached. I haven't finished working on my templates and views yet but I will p

Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-22 Thread Bill Freeman
I guess this is probably because the request.user object is created on demand (is a python "property"). The intent, I presume, is to not bother fetching the session, etc., unless it is used, as an optimization. You should find that simply referring to request.user in the view helps. If so, then

CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-21 Thread Alexis Bellido
Hello, I am working on a Django 1.4 project and writing one simple application using per-site cache as described here: https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache I have correctly setup a local Memcached server and confirmed the pages are being cached. Then I set CA