Friday, August 24, 2012

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

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
> users, I just needed to access some method or attribute to triggers an
> actual query on the User object. I ended up with this, which I think it's
> the simplest way:
>
> bypass_lazyload = request.user.is_authenticated()

I agree that it's a POLA-violation and you should probably file a bug
report. I would expect that setting CACHE_MIDDLEWARE_ANONYMOUS_ONLY
would call request.user.is_anonymous() and as such load the lazy object.
For this to work, the cache middleware should probably be later in the
sequence then the authentication middleware.

--
Melvyn Sopacua

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate