Opened 17 years ago

Closed 17 years ago

#5921 closed (wontfix)

Common parent class for User and AnonymousUser

Reported by: jag@… Owned by: nobody
Component: Contrib apps Version: dev
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Howdy!

While I know of and respect Django's deference to Pythonic duck-typing, it would be helpful for isinstance(obj, klass) to confirm whether an object is a user or not, regardless of authentication. However User inherits solely from models.Model and AnonymousUser inherits from object -- they have no common lineage despite common interface.

This patch creates an abstract parent class for both User and AnonymousUser so a check for isinstance(obj, django.contrib.auth.models.UserClass) returns True whether the user is authenticated or not.

It provides this functionality without any other modification to the external interface, so there are no side-effects or other impacts of this change. I've tested it against the Django test suite and it passes.

-jag

Attachments (2)

common-parent-class-for-user-and-anonymoususer.patch (3.5 KB ) - added by Joshua "jag" Ginsberg <jag@…> 17 years ago.
Patchfile
common-parent-class-for-user-and-anonymoususer.2.patch (2.1 KB ) - added by Joshua "jag" Ginsberg <jag@…> 17 years ago.

Download all attachments as: .zip

Change History (5)

by Joshua "jag" Ginsberg <jag@…>, 17 years ago

Patchfile

by Joshua "jag" Ginsberg <jag@…>, 17 years ago

comment:1 by Joshua "jag" Ginsberg <jag@…>, 17 years ago

Forgive my daftness -- the first patchfile was the wrong version and should be deleted from the ticket.

comment:2 by Simon G <dev@…>, 17 years ago

Summary: [PATCH] Common parent class for User and AnonymousUserCommon parent class for User and AnonymousUser
Triage Stage: UnreviewedDesign decision needed

comment:3 by Jacob, 17 years ago

Resolution: wontfix
Status: newclosed

Generally we look down upon abstract base classes in Python and Django. That's especially true when the base class doesn't actually provide any functionality. So while I appreciate your desire to use isinstance/issubclass, this patch just doesn't fit.

Note: See TracTickets for help on using tickets.
Back to Top