Opened 15 years ago
Closed 15 years ago
#12060 closed (fixed)
Auth Context Processor returns user as a Lazy Object, which breaks things
Reported by: | Eric Holscher | Owned by: | Luke Plant |
---|---|---|---|
Component: | contrib.auth | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
With the addition in r11621, when a template checks the type or equality of request.user given from the auth context processor, you used to get:
ipdb> type(response.context['user']) Out[0]: <class 'django.utils.functional.SimpleLazyObject'>
Previously, this returned an auth.User object.
<class 'django.contrib.auth.models.User'>
Attached is a test that fails with the current trunk. It passes with the current test structure and pre-r11621 auth context_processor.
Attachments (1)
Change History (6)
by , 15 years ago
Attachment: | 12060.diff added |
---|
comment:1 by , 15 years ago
comment:2 by , 15 years ago
I have a very simple use case:
Filter:
@register.filter def is_equal(obj, arg): "Returns a boolean of whether the value is equal to the argument" return obj == arg
Template (assuming a user is logged in):
{% if user|is_equal:book.user %} do something {% endif %}
This currently returns False if the user is in fact the same as the book user since it's being evaluated against 'SimpleLazyObject' instead of the actual user object.
comment:3 by , 15 years ago
This was also referenced on django-users as well:
http://groups.google.com/group/django-users/browse_thread/thread/e2255f9735fc888a
comment:4 by , 15 years ago
Owner: | changed from | to
---|
The attached test is not helpful, because it is effectively doing type checking. But testing for equality with a SimpleLazyObject-wrapped object ought to work, and that will be fixed.
comment:5 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note that I meant r11623