On 05/10/2011 04:00 PM, Andy wrote:
Thank you.

So LazyUser is there to cache the user instance.

Not exactly. It appears to be 'lazy' in that it doesn't actually do a database lookup to get the user until it has to.
Read the LazyUser code and you'll see.

In LazyUser(object), the user instance is stored in
request._cached_user

In AuthenticationMiddleware(object), the user instance is stored in
request.__class__.user

But I don't see request.user being assigned at all. Where does that
happen?
In LazyUser, when it calls the get_user function. Using request.user in your code will call __get__ on the LazyUser instance, and it'll actually get the real User instance via the get_user function (unless it's already cached, of course).

Shawn

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

Reply via email to