#30941: hasattr(request, '_cached_user') check no longer works
---------------------------------+--------------------------------------
     Reporter:  Collin Anderson  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  contrib.auth     |                  Version:  master
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------
Description changed by Collin Anderson:

Old description:

> Before 2f01079, it was possible to check to see whether the lazy user has
> been evaluated or not using `hasattr(request, '_cached_user')`. This was
> undocumented, but used a lot:
> https://github.com/search?q=_cached_user&type=Code
>
> I think we should try to maintain backwards compatibility for that that
> check, and document and test it. (Or if nothing else, document and test
> the new behavior and add a release note.)
>
> This is really helpful in middleware to be able to check this, so you can
> access the user if it has already been accessed, but can avoid fetching
> user if it hasn't already been fetched.

New description:

 Before 2f01079, it was possible to check to see whether the lazy user has
 been evaluated or not using `hasattr(request, '_cached_user')`. This was
 undocumented, but used a lot:
 
https://github.com/search?q=hasattr%28request%2C+%27_cached_user%27%29&type=Code

 I think we should try to maintain backwards compatibility for that that
 check, and document and test it. (Or if nothing else, document and test
 the new behavior and add a release note.)

 This is really helpful in middleware to be able to check this, so you can
 access the user if it has already been accessed, but can avoid fetching
 user if it hasn't already been fetched.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30941#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.d6e7ef9f9f9347362361c38effa7ece2%40djangoproject.com.

Reply via email to