#25847: Make User.is_authenticated() and User.is_anonymous() "callable 
properties"
-------------------------------+------------------------------------
     Reporter:  skorokithakis  |                    Owner:  jlaine
         Type:  New feature    |                   Status:  assigned
    Component:  contrib.auth   |                  Version:  1.9
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------

Comment (by jlaine):

 I have put up a pull request here:

 https://github.com/django/django/pull/6376

 @apollo13 mentioned that we might want to support the case where a custom
 user model defines is_anonymous / is_authenticated as methods instead of
 properties. In this case we could do something like this to monkey-patch
 that user model to the new style:

 {{{
     def __new__(cls):
         if not isinstance(cls.is_anonymous, property):
             real_is_anonymous = cls.is_anonymous
             cls.is_anonymous = property(lambda x:
 CallableBool(real_is_anonymous(x)))
         return super(AbstractBaseUser, cls).__new__(cls)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25847#comment:8>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.d9f24170b52cda69992279435a86cf81%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to