Opened 18 years ago
Closed 18 years ago
#5921 closed (wontfix)
Common parent class for User and AnonymousUser
| Reported by: | 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)
Change History (5)
by , 18 years ago
| Attachment: | common-parent-class-for-user-and-anonymoususer.patch added |
|---|
by , 18 years ago
| Attachment: | common-parent-class-for-user-and-anonymoususer.2.patch added |
|---|
comment:1 by , 18 years ago
Forgive my daftness -- the first patchfile was the wrong version and should be deleted from the ticket.
comment:2 by , 18 years ago
| Summary: | [PATCH] Common parent class for User and AnonymousUser → Common parent class for User and AnonymousUser |
|---|---|
| Triage Stage: | Unreviewed → Design decision needed |
comment:3 by , 18 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
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.
Patchfile