Right, right and right.

Tim, I somehow missed that suggestion. It is certainly workable.

Markus, Custom user classes which do not inherit AbstractBaseUser are a point 
I hadn't considered, and in fact they make my suggestions problematic, leaving 
_only_ the checks approach.

However, descriptors which aren't properties should also be acceptable... in 
particular, even plain attributes. I would consider writing the check not as

        if not isinstance(cls.is_anonymous, property):

but instead using

        if not isinstance(cls().is_anonymous, bool):

or even 

        if isinstance(cls().is_anonymous, six.types.MethodType):

which assumes that if there's anything other than a method on the instance, 
then the user probably knows what they're doing.

The problem with these suggestions is that they create a user object during 
checks, and that might be an obstacle for some users (side effects and required 
initializer parameters are the two most obvious issues).

Shai.

Reply via email to