Changes between Initial Version and Version 2 of Ticket #26988


Ignore:
Timestamp:
Aug 2, 2016, 5:38:10 AM (8 years ago)
Author:
Mark Tranchant
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26988

    • Property Summary User is_authenticated callable property confusing if used with "is False"User is_authenticated callable property is confusing to check
    • Property Easy pickings set
  • Ticket #26988 – Description

    initial v2  
    1 Just upgraded to 1.10, converted all {{{ is_authenticated() }}} methods into {{{ is_authenticated }}} properties as per the [https://docs.djangoproject.com/en/1.10/releases/1.10/#using-user-is-authenticated-and-user-is-anonymous-as-methods Release Notes] and a test in my test suite failed.
     1Just upgraded to 1.10, converted all {{{is_authenticated()}}} methods into {{{is_authenticated}}} properties as per the [https://docs.djangoproject.com/en/1.10/releases/1.10/#using-user-is-authenticated-and-user-is-anonymous-as-methods Release Notes] and a test in my test suite failed.
    22
    3 It turns out I was checking for a logged in user with {{{ if request.user.is_authenticated is False: }}}, but the {{{ is_authenticated }}} property is actually a {{{ CallableBool() }}} so is not False under any circumstances.
     3It turns out I was checking for a logged in user with {{{if request.user.is_authenticated is False:}}}, but the {{{is_authenticated}}} property is actually a {{{CallableBool}}} which cannot be tested with {{== False}}, {{is False}}, {{== True}} or {{is True}}.
    44
    5 Checking this property only gives logical results with direct {{{ if user.is_authenticated }}} or {{{ if not user.is_authenticated }}}. This is very misleading and non-intuitive behaviour and should be fixed or strongly called out in the documentation. Example:
     5Checking this property only gives logical results with direct {{{if user.is_authenticated}}} or {{{if not user.is_authenticated}}}. This is very misleading and non-intuitive behaviour (at odds with [https://www.python.org/dev/peps/pep-0008/#programming-recommendations PEP8 (bottom of linked section)] and should be fixed or strongly called out in the documentation. Example:
    66
    77{{{
Back to Top